in reply to Newbie: 'For loops'
Short answer: $ItemList[$i][0] refers to an entry in a two dimensional array.
For loops as you have written are not frequently used by perl programmers. (It makes you look as if you have just come from C). Instead we tend to use foreach loops because they are clearer, and avoid some types of bugs (Such as getting the index wrong and jumping off the end of the array). Re-writing your snippet with a foreach loop we get:
my $i=0; foreach my $Item ( @itemList ) { print "Item $i is $Item[3]\n", " Name: $Item[0]\n", " Amount: $Item[1]\n", " Process: $Item[2]\n\n"; $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Newbie: 'For loops'
by Anonymous Monk on Nov 30, 2010 at 15:10 UTC | |
|
Re^2: Newbie: 'For loops'
by packetstormer (Monk) on Nov 30, 2010 at 15:05 UTC |