George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:
But as far as I can see this means that whenever the CGI is called it compiles all the different subroutines, even though it actually only ever runs one of them. And this is true whether the subs are in a lib or in the script itself.if ($Action eq 'foo') { &foo; } elsif ($Action eq 'bar') { &bar; } else { &baz; }
Now, I can see one reason why this is bad: errors don't show up so easily - you just get a blank screen if foo.pl is n.b.g. But actually that's not too bad, because they're all fairly stable scripts that don't need to change much - and if I'm getting errors, that's a bigger problem than just not being able to track them very easily.if ($Action eq 'foo') { do 'foo.pl'; } elsif ($Action eq 'bar') { do 'bar.pl'; } else { do 'baz.pl'; }
|
---|