[sf-perl] Can't figure this one out

Joe Brenner doom at kzsu.stanford.edu
Wed Mar 5 17:23:19 PST 2008


nheller at silcon.com wrote:

> Here's an error that I can't figure out for the life of me.
> The code is short; I can't figure out why the compiler thinks $action (on
> the marked line) is a bare word.
>
> The actual error message follows the source code.
> I would really appreciate any help.
>
> {
>     my ($q, $ins, $action, %p, $p);
>
>     $q = new CGI;
>     $action = $q->param('action');
>     $action = 'start' unless $action;
>
>     if ($action =~ /start/i) {     <-------- line 511, the offender
>         &MainPage($q, \%p);
>     }
>     elsif ($action =~ /new/i ||
>            $action =~ /del/i ||
>            $action =~ /edt/i ||
>            $action =~ /save/i )
>     {

My experience has been that with compound booleans like this,
you're better off using more parens than you think you need:


     elsif ( ($action =~ /new/i) ||
             ($action =~ /del/i) ||
             ($action =~ /edt/i) ||
             ($action =~ /save/i) )



More information about the SanFrancisco-pm mailing list