in reply to Re^4: Counting Problem
in thread Counting Problem
You could use slot 0 of your array to hold the count, and let the names occupy slots 1..n. That would give you a structure like:
my %AG = ( 'OfficeOfDir' => [ 5, # slot 0 holds count { GRADE=>'A', POSITION=>'Quarterback', NAME=>'Unitas, J.' }, { GRADE=>'B', POSITION=>'Nickleback', NAME=>'Elephino' }, ], 'OfficeOfTech' => [ 2, { GRADE=>'B2', POSITION=>'Secretary', NAME=>'BillTheGalacticHe +ro' }, { GRADE=>'C5', POSITION=>'Diplomat', NAME=>'StainlessSteelRat +' }, ], );
There are many alternatives, though. You need to come up with something that feels natural to you, and you find easy to work with in your code.
Also, I wasn't kidding when I mentioned:
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Counting Problem
by GuiPerl (Acolyte) on Sep 12, 2014 at 14:18 UTC | |
by roboticus (Chancellor) on Sep 12, 2014 at 17:11 UTC |