Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Multiple keys for a hash table row?

by jeffa (Bishop)
on Dec 10, 2015 at 19:49 UTC ( #1149930=note: print w/replies, xml ) Need Help??


in reply to Multiple keys for a hash table row?

Just make new hash keys that reference the original keys' values:

use strict; use warnings; my %foo = ( "GENERATE" => "10 14 00 07 4d", "DELIVER" => "16 75 32 14 77" ); $foo{CREATE} = \$foo{GENERATE}; $foo{DELIV} = \$foo{DELIVER}; use Data::Dumper; print Dumper \%foo;

However, now you need to de-reference the values to use them:

print ${ $foo{CREATE} }, $/;

I recommend just duplicating the data:

$foo{CREATE} = $foo{GENERATE}; $foo{DELIV} = $foo{DELIVER};
Unless you know you will be dealing with million and millions of hash keys. Clarity is very important. Also, check the CPAN for modules that allow you to alias hash keys.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Multiple keys for a hash table row?
by mike65535 (Novice) on Dec 10, 2015 at 20:41 UTC
    I'll have very few hash keys (a dozen or so).

    Likely I'll have way more aliases.

    Thanks.

    Mike

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-10-21 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (119 votes). Check out past polls.

    Notices?