Consider the following:
use strict;
use Data::Dumper;
my $hash={['one','two']=>[1,2]};
print Dumper($hash);
=for comment
prints....
$VAR1 = {
'ARRAY(0x35358)' => [
1,
2
]
};
=cut
As an alternative, the key in the hash can be constrcuted as "one\ttwo" and then I can separate out the elements of the key based on tab delimiter (in latter part of the program while munging the data).
Any advice on how to store the key as a array reference?
No, a normal (non-tie
d) Perl hash can only have strings as keys. Anything else - arrayrefs, objects, whatever - will be stringified if used as a hash key, which leaves the hash key unusable as whatever non-string thing you originally had.
Hash::MultiKey uses the magic of tie
to sidestep this restriction.
Hash::MultiKey
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With