in reply to Re: Detecting a post via cgi
in thread Detecting a post via cgi

A somewhat cleaner way of doing what you accomplish:

my $param = $cgi->param('foo') || ''; if ($param) { #... }

Or, if you always untaint your variables:

my $_param = $cgi->param('foo') || ''; my ($param) = $_param =~ /^($some_regex)$/;

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

Replies are listed 'Best First'.
Re: Re: Re: Detecting a post via cgi
by cbro (Pilgrim) on May 28, 2003 at 15:15 UTC
    Very true Ovid. I'm a C programmer...cut me some slack ;o). Seriously though...that's a nice space saver, and I will change my Perl methodology to reflect that 'cleaner' way of instantiation. I post some help to somebody and get help back. Yes, this is a great site.

      No worries. I certainly didn't intend for that to come across as a rebuke. Sometimes people are a little too blunt when they post. I try not to be one of them but it looks like I was :)

      Cheers,
      Ovid

      New address of my CGI Course.
      Silence is Evil (feel free to copy and distribute widely - note copyright text)

        Actually, it would seem that's what I did. I didn't mean to write a 'rebuke'. I was seriously saying (and only meant to come across as saying) "Thank You". I gave your post a ++; it was good advice. And the 'C programmer' comment, albeit true, was just a joke.