Tanalis has asked for the wisdom of the Perl Monks concerning the following question:
I need to find the length of each variable-length array in a hash of arrays. My code atm is as follows:
foreach my $key (keys %valid) { for (my $i = 0; $i < $#[valid{$key]}; $i++) { print STDERR "$key: $valid{$key}[$i]\n"; } }
which doesn't work - Perl complains about $#[valid{$key}]. I can't seem to work round this - any advice would be a great help.
-- Foxcub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding the length of an array in a hash of arrays
by Aristotle (Chancellor) on Aug 26, 2002 at 12:08 UTC | |
|
Re: Finding the length of an array in a hash of arrays
by thinker (Parson) on Aug 26, 2002 at 12:37 UTC | |
|
Re: Finding the length of an array in a hash of arrays
by dreadpiratepeter (Priest) on Aug 26, 2002 at 12:20 UTC | |
by vek (Prior) on Aug 26, 2002 at 13:28 UTC |