[sf-perl] Can't figure this one out
Joe Brenner
doom at kzsu.stanford.edu
Wed Mar 5 17:26:16 PST 2008
Sergey Fetisov <sergey.fetisov at ask.com> wrote:
> nheller at silcon.com wrote:
>
> >> if ($action =~ /start/i) { <-------- line 511, the offender
> >> &MainPage($q, \%p);
> >> }
> >> elsif ($action =~ /new/i ||
> >> $action =~ /del/i ||
> >> $action =~ /edt/i ||
> >> $action =~ /save/i )
> >> {
> >>
> >> [imiuser at adopt nheller]$ perl -c ad_cases.cgi Bareword "action" not
> >> allowed while "strict subs" in use at ad_cases.cgi line 511.
> >> ad_cases.cgi had compilation errors.
> >The "at line 511" really means "the statement that starts on line 511"
>
> >but it looks like you have a cascading if/else chain, and so the ENTIRE
> CHAIN is "at line 511".
>
> >Break up the else/ifs and you'll get a better pointer to the offending
> line.
> ------------
>
> Yep, seems like a some line inside of the if/else statement caused the
> error
>
> By the way
>
> if ($action =~ /start/i) {
> &MainPage($q, \%p);
> } elsif ($action =~ /new|del|edt|save/i ) {
>
> {
>
> seems better to me
It's more compact, but I bet it runs slower. This might even be a
case where performance matters (i.e. if the cgi script sees a lot of
traffic).
More information about the SanFrancisco-pm
mailing list