On Mar 17, 2:46 pm, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote:
> Kashif Salman wrote:
> > I have a CGI script; when it runs the very first time I define some 
> > variables
> > my $action = $q->param('action');
>
> > The first time it runs, parameter 'action' isn't defined so that is
> > how I check that it is running the first time and do my things
>
> > if ($aciton eq "") {...}
> > elsif ($action eq "submit") {...}
>
> > the elsif runs if I hit a button on a form which has a hidden field
> > that sets action="submit". My question is that the script produces a
> > warning on the if statement " Use of uninitialized value in string eq
> > ". How can I get rid of that without using "no warnings". I tried 'if
> > (defined("$action"))' but that still produces a warning.
>
>      if ( ! $action ) {...}

That'll work great until some jackass puts "?action=0" in the URL.

Using defined() is correct.  It's what he's passing to defined()
that's not.

Paul Lalli


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to