in reply to How do I access values in a hash by two different keys?
If you keep filename as your key, you could write your loop as
for my $i ( keys %{ $config->{item} } ) { print $config->{item}->{$i}->{id}, ": "; print $config->{item}->{$i}->{destination_dir}, "\n"; }
If you need it sorted by id, it goes like this:
for my $i (sort { $config->{item}->{$a}->{id} <=> $config->{item}->{$b +}->{id} } keys %{ $config->{item} } ) { print $config->{item}->{$i}->{id}, ": "; print $config->{item}->{$i}->{destination_dir}, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I access values in a hash by two different keys?
by turbodizik (Initiate) on Jul 19, 2013 at 09:12 UTC | |
by hdb (Monsignor) on Jul 19, 2013 at 09:22 UTC | |
by turbodizik (Initiate) on Jul 19, 2013 at 09:45 UTC |