Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Multiple keys for a hash table row?

by SuicideJunkie (Vicar)
on Dec 10, 2015 at 19:53 UTC ( [id://1149931]=note: print w/replies, xml ) Need Help??


in reply to Multiple keys for a hash table row?

If your values are simple, you can just make copies such as by saying:

my %commands; $commands{$_} = "10 14 00 07 4d" for qw(GENERATE CREATE SPAWN ETC); $commands{$_} = "16 75 32 14 77" for qw(DELIVER DELIV SHIP ETC2);

If your values are more complex (IE; references to larger things), then simply make both references point to the same object.

my %commands; my $createCMD = {weight=>10, coordinates=>[42,-3.14], logic=>sub{ ... +}, sound=>'success.mp3'}; $commands{$_} = $createCMD for qw(GENERATE CREATE SPAWN);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found