WearyTraveler has asked for the wisdom of the Perl Monks concerning the following question:
I have a list of transactions:01 Joe 02 Ed 03 Sam 04 Wendy
I want to read through my transactions file, and push the 3rd field onto the tail end of the array associated with each employee. I don’t want to:yadda 01 abc yadda 03 sss yadda 02 asdsdbc yadda 02 adfgbc yadda 01 abgxvc yadda 02 azdfbc yadda 04 azdfbc yadda 04 abdc
I want to:foreach (@transactions) { #there are dozens of employee numbers… if ($_ eq 01) { push (@joe , $_) ; } if ($_ eq 02) { push (@ed , $_) ; } if ($_ eq 03) { push (@sam , $_) ; } if ($_ eq 04) { push (@sam , $_) ; } if (no others) { push (@unregistered , $_) ; } }
I want to use all these arrays later to print off different reports. Any help would be appreciated!foreach (@transactions) { push (@the_correct_employee’s_array_based_on_number , $_) ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using a number to determine which array to push onto
by kennethk (Abbot) on Dec 20, 2010 at 20:14 UTC | |
by ikegami (Patriarch) on Dec 20, 2010 at 20:18 UTC | |
|
Re: Using a number to determine which array to push onto
by roboticus (Chancellor) on Dec 20, 2010 at 20:21 UTC | |
by WearyTraveler (Novice) on Jan 08, 2011 at 18:59 UTC |