#!/usr/bin/python
a = { 'b' : { 'c' : 1 } }
for i in a.values():
for k in i.values():
print k
It is simply a nested loop iteration over a hashtable of hashtables of ints. However, in Perl, this requires a confusing spurious %{ $i }. That's alot of punctuation. This punction is basically telling perl that even though $i needs to be a scalar inside the context of the foreach loop, it should force it to be a hash for the purpose of the input to the next foreach. I challenge you to show us all another way. Here is the code:
#/usr/bin/perl
$a{"k"}{"r"} = 1;
foreach $i (values %a) {
foreach $j (values %{ $i }) {
print "$j\n";
}
}
Posted by jeske at August 15, 2003 5:02 PM