cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:
Well, unexpected to me...
#!/usr/bin/perl use strict; use warnings; use Data::Dumper 'Dumper'; use CGI; my $q = CGI->new(); my $var = { first => $q->param('first'), second => $q->param('second'), }; print Dumper($var);
What do you expect $var to be? I expected
$VAR1 = { 'first' => undef, 'second' => undef, };
What I got was:
$VAR1 = { 'first' => 'second' };
To me, this is unexpected behavior. This is the line that gives us this:
return unless defined($name) && $self->{$name};
Changing it to:
return undef unless defined($name) && $self->{$name};
gives me the behavior I expect. But, is there a reason why the line as it stands is more correct than my interpretation? Am I the only person who thinks that the current implementation feels wrong?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unexpected CGI param behavior
by pc88mxer (Vicar) on Jun 24, 2008 at 00:47 UTC | |
Re: Unexpected CGI param behavior
by NetWallah (Canon) on Jun 24, 2008 at 00:54 UTC | |
Re: Unexpected CGI param behavior
by runrig (Abbot) on Jun 24, 2008 at 00:42 UTC | |
Re: Unexpected CGI param behavior
by ysth (Canon) on Jun 24, 2008 at 03:19 UTC | |
by Anonymous Monk on Jun 24, 2008 at 09:28 UTC | |
Re: Unexpected CGI param behavior
by cLive ;-) (Prior) on Jun 24, 2008 at 20:35 UTC | |
by ikegami (Patriarch) on Jun 24, 2008 at 20:39 UTC | |
by cLive ;-) (Prior) on Jun 25, 2008 at 06:25 UTC | |
by ikegami (Patriarch) on Jun 25, 2008 at 07:37 UTC |
Back to
Seekers of Perl Wisdom