In a foreach loop, is there a way to find out the loop index number?
E.g.:

foreach (@myarray)
{
...
push(@newarray[<??loopindex??>], <somevalue>);
...
}

Currently, I have to resort to the following:
for (my $i= 0; $i <= $#myarray, $i++)
{ ... push(@newarray[$i], <somevalue>); ...}

 ... which is more wordy -- I was wondering if there's a more
elegant/efficient (i.e. less code) to do this?
Thanks,

-Nilanjan


Nilanjan Palit
__________________________________________
Infrastructure Processor Division, CIG/DEG
Intel Massachusetts Development Center
Email: [EMAIL PROTECTED]

 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to