Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: multiple keys - one value

by QM (Parson)
on Dec 04, 2003 at 07:10 UTC ( [id://312134]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: multiple keys - one value
in thread using a hash of functions

I suspect it's because $h{HELP} doesn't exist when you create the tuple Q=>$h{HELP}, as %h hasn't been assigned to at that time.

Perhaps this will work for you:

use Data::Dumper; my %h=( HELP => sub {print qq(help\n)}, SAVE=>sub{print qq(save\n)} ); $h{Q} = $h{HELP}; print Dumper(%h); print $h{Q}();
Result:
$VAR1 = 'Q'; $VAR2 = sub { "DUMMY" }; $VAR3 = 'HELP'; $VAR4 = $VAR2; $VAR5 = 'SAVE'; $VAR6 = sub { "DUMMY" }; help 1
Note that HELP and Q both use the same sub.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

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

    No recent polls found