Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Take one url:
http://dev/remove.cgi?action=confirm&kdate=987807599&name=Test
mix with the Wonderous piece of Perl
my $killdate = param{"kdate"}; my $killname = param("name");
which yields:
$killdate as "", $killname as "Test"

Now, I'm obviously missing something blindingly obvious here, but I can't see the wood for the trees today -- hence I come seeking wisdom :o)

Any ideas where I'm being stupuid??

Thanks!

Replies are listed 'Best First'.
Re: wierd CGI::Param() behaviour
by ChOas (Curate) on Jan 10, 2001 at 16:42 UTC
    Hi!

    You might wanna use '(' ')' instead of '{' '}'
    on that first call to param instead of only on the
    2nd one ;))

    GreetZ!,
      ChOas

    print "profeth still\n" if /bird|devil/;
      Yes, I feel like a Class one fool now... I'll go and sit in the corner with a dunce cap -- after changing my fint settings for one that makes () and {} look more different :o)

      Thanks, though!

Re: wierd CGI::Param() behaviour
by Fastolfe (Vicar) on Jan 10, 2001 at 18:47 UTC
    Note that that first line is being interpreted sorta like this:
    my $killdate = param( {"kdate"} ); # passing a hashref
    If you had run Perl with the -w option (or 'use warnings' under 5.6) to run with warnings on, you would have seen that there was a problem here:
    Odd number of elements in hash assignment at test line 9.
    Always build your code to run under strict and warnings, or, at the very least, turn these on when you're debugging strange behavior. More often than not, they will point to your problem (or at least a symptom of it).
Re: wierd CGI::Param() behaviour
by OeufMayo (Curate) on Jan 10, 2001 at 16:46 UTC
    my $killdate = param{"kdate"}; ^ curly brackets my $killname = param("name"); ^ parens

    No need for curly brackets here!

    <kbd>--
    PerlMonger::Paris(http => 'paris.pm.org');</kbd>