<?xml version="1.0" encoding="windows-1252"?>
<node id="1020128" title="Index of Items in Array using foreach loop" created="2013-02-22 05:44:29" updated="2013-02-22 05:44:29">
<type id="115">
perlquestion</type>
<author id="1020114">
default_user</author>
<data>
<field name="doctext">
In the following example I create an additional variable to keep track where I am in the array.

&lt;code&gt;
my @SampleArray = ("one","two","three" );
my $Arrayindex = 0;
foreach my $ArrayItem ( @SampleArray ){
    print $ArrayItem , ' is at location ' , $Arrayindex , ' in the array' , "\n";
    $Arrayindex++;
}
&lt;/code&gt;

The question, is there a more efficient way to do this? I don't  like having to use the &lt;code&gt;$Arrayindex++;&lt;/code&gt; method to achieve this.</field>
</data>
</node>
