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

Re: Multiple keys for a hash table row?

by jeffa (Bishop)
on Dec 10, 2015 at 19:49 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1149930]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found