in reply to Re: null keys
in thread null keys

The syntax works fine for me, $hash is just the hash of code referances $params->{action} is just the key for which one to call. Here is the surrounding code.

my $q =new CGI; my $params=$q->Vars(); my %hash=('sub1'=>\&sub1,'sub2'=>\&sub2, ''= >\&notfound); main(); sub main { #call the sub as defined by cgi param 'action' &$hash{$params->{'action'}}->() ; }

Thanks all for the tip on pushing undef, don't know if I asked much of a question was just checking this is 'normal' behaviour Update My mistake somehow added quotes when retyping

Replies are listed 'Best First'.
Re: null keys
by Abigail-II (Bishop) on Jun 13, 2002 at 09:03 UTC
    The syntax works fine for me

    For which version of Perl and which platform? I just tried compiling the program on every version of Perl since 5.000, and it just doesn't compile on any version.

    $hash is just the hash of code referances

    No, it's not. The values in the hash are strings, not code references. Had you dropped the quotes, then it would be code references.

    Abigail