I have code that looks like this:
$action = param('action');
if ($action eq 'process_send_pm') { process_send_pm(); }
elsif ($action eq 'process_purge') { process_purge(); }
elsif ($action eq 'process_folders') { process_folders(); }
elsif ($action eq 'process_ignore') { process_ignore(); }
elsif ($action eq 'process_modify_profile') { process_modify_profile(); }
I was thinking about changing it to this, for the sake of brevity:
if (
$action eq 'process_send_pm' ||
$action eq 'process_purge' ||
$action eq 'process_folders' ||
$action eq 'process_ignore' ||
$action eq 'process_modify_profile') { &{$action}; }
I keep reading that this is a bad idea, but... why? If I'm testing to make sure that $action matches pre-approved strings before sending, am I still opening up to an unforeseen problem?