Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: multiple keys - one value

by NetWallah (Canon)
on Dec 05, 2003 at 05:58 UTC ( [id://312441]=note: print w/replies, xml ) Need Help??


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

OK I answered my own question based on one of my old writeups. It IS possible to eliminate the temporary variable by coding as follows:
use strict; my %h; #Pre-declare so it can be referenced inside populating code %h=( HELP => sub {print qq(help\n)}, '?'=>sub{$h{HELP}()}, SAVE=>sub{print qq(save\n)}, EXIT=>sub{$h{SAVE}()} ); $h{'?'}(); $h{EXIT}();
This prints the lines:
help
save

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found