Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?
[erix]: This sad, embarrassing wreck of a man

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2018-07-17 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (378 votes). Check out past polls.

    Notices?