in reply to hash pointing to AoA
An additional (interesting?) question would be: how can I create an AoA on a hash key 'in place', for example I want to create a 10x10 boolean array that is located in a hash under a specific key, e.g.:
# example: build a 10x10 boolean field on a hash key my $key='10x10'; my %hash; for my $row (0..9) { for my $col (0..9) { push @{ $hash{$key}[$row] }, int(rand()+0.5); } }
Afterwards, we could run through our array by iteration over indexes:
for my $row (0..9) { for my $col (0..9) { print "{$key} => [$row][$col] = $hash{$key}[$row][$col] \n" } }
Regards
mwa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash pointing to AoA
by NetWallah (Canon) on May 19, 2008 at 16:35 UTC |