develooper Front page | perl.perl5.porters | Postings from December 2003

Re: [perl #24760] submit() of CGI.pm generates warning if -sticky used

Thread Previous
From:
Rafael Garcia-Suarez
Date:
December 28, 2003 13:46
Subject:
Re: [perl #24760] submit() of CGI.pm generates warning if -sticky used
Message ID:
20031228225203.3bc1c5a0.rgarciasuarez@free.fr
musiphil@bawi.org (via RT) wrote:
> 
> I found that "Use of uninitialized value in concatenation (.) or string"
> warnings were filling up the error log of the web server. So I tracked
> down the problem to the simple script below:
> 
> #!/usr/bin/perl -w
> use CGI qw(-nosticky);
> CGI->submit;
> 
> Run this and it will generate the following warning:
> 
> Use of uninitialized value in concatenation (.) or string at (eval 2) line 15.
> 
> The problem seems to be with submit() of CGI.pm (version 2.752);
> I found the following line in 'sub submit':
> 
>     my($name) = ' name=".submit"' unless $NOSTICKY;
> 
> if $NOSTICKY is set, $name remains undef and it will cause the warning
> in subsequent interpolations. It should be changed like this:
> 
>     my($name) = $NOSTICKY ? '' : ' name=".submit"';
> 
> and the warnings go away.

This seems to be a good solution. The problem still exists in CGI 3.01.

May I point out, additionnally, what the perlsyn manpage says about this
kind of construct :

    NOTE: The behaviour of a "my" statement modified with a
    statement modifier conditional or loop construct (e.g. "my
    $x if ...") is undefined.  The value of the "my" variable
    may be "undef", any previously assigned value, or possibly
    anything else.  Don't rely on it.  Future versions of perl
    might do something different from the version of perl you
    try it out on.  Here be dragons.

Currently this construct can be used to generate kinda-static variables,
but I wouldn't rely on it.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About