Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Using a regex as a hash key

by ikegami (Patriarch)
on Jun 06, 2007 at 17:00 UTC ( [id://619629]=note: print w/replies, xml ) Need Help??


in reply to Using a regex as a hash key

$functions{$var1} returned undef because none of the regexp keys matched, so $functions{$var1}->($var2) gives that error. The fix is to check whether a key was found in the hash:

my $handler = $functions{$var1}; if (not defined $handler) { ... } my $result = $handler->($var2);

Perhaps it's because you never assigned a value to $var1?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://619629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found