in reply to can't use certain hashnames when traversing a slightly complex hash
I get to the filename with this:
foreach my $g (@gists) { my @files = keys(%{$g->{files}}); my $file = $files[0]; # $file is now main.html ... }
One final note. The code quoted from the OP works as commented if and only if there is exactly one key in the 'files' sub-hash (and, of course, the name of the key is 'main.html'). If there are two or more keys, the 'order' of keys in the hash is not guaranteed whatsoever, so 'main.html' might be at index 0, index 1, ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: can't use certain hashnames when traversing a slightly complex hash
by gideondsouza (Pilgrim) on Jan 06, 2013 at 15:46 UTC | |
by AnomalousMonk (Archbishop) on Jan 06, 2013 at 16:19 UTC | |
by gideondsouza (Pilgrim) on Jan 07, 2013 at 05:49 UTC |
In Section
Seekers of Perl Wisdom