default_user has asked for the wisdom of the Perl Monks concerning the following question:
The question, is there a more efficient way to do this? I don't like having to use the $Arrayindex++; method to achieve this.my @SampleArray = ("one","two","three" ); my $Arrayindex = 0; foreach my $ArrayItem ( @SampleArray ){ print $ArrayItem , ' is at location ' , $Arrayindex , ' in the arr +ay' , "\n"; $Arrayindex++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Index of Items in Array using foreach loop
by tobyink (Canon) on Feb 22, 2013 at 10:50 UTC | |
|
Re: Index of Items in Array using foreach loop
by tmharish (Friar) on Feb 22, 2013 at 10:48 UTC |