in reply to Using a number to determine which array to push onto
Then try an array of arrays, then you can use the number as the array index:
my @AoA; foreach (@transactions) { #there are dozens of employee numbers… push @{$AoA[$_]}, $_; }
You can use index 0 for your "unregistered" array, and the natural numbers (1..n) for your arrays. (Note: you used $_ as the value and for the array choice, so I didn't change that in the snippet above. You'll want to have a separate value and index...
Even better could be a hash of arrays, then you can use something like:
my %HoA; foreach (@transactions) { my ($name, $num, $value) = ...; $HoA{NAME} = $name; $HoA{NUM} = $num; push @{$HoA{VALS}}, $value; }
Read perldoc perldsc, perldoc perllol for some hints...
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a number to determine which array to push onto
by WearyTraveler (Novice) on Jan 08, 2011 at 18:59 UTC |