in reply to Re^2: How do I access values in a hash by two different keys?
in thread How do I access values in a hash by two different keys?
Have a look at your data structure using Data::Dumper:
use Data::Dumper; print Dumper $config; gives you $VAR1 = { 'item' => { 'AMEX' => { 'destination_dir' => 'test', 'id' => 0 }, 'bla' => { 'destination_dir' => 'test1', 'id' => 1 }, 'alb' => { 'destination_dir' => 'test2', 'id' => 2 } } };
So $config->{item} represents a reference to a hash with keys "AMEX", "bla", and "alb". If you try $config->{item}->{1}->{destination_dir}; you are using a key that does not exist, the string "1".
UPDATE: I probably should state explicitely that there is no numeric index in a hash and that there is no defined order of items in a hash that you can rely on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How do I access values in a hash by two different keys?
by turbodizik (Initiate) on Jul 19, 2013 at 09:45 UTC |