Good day;
I'm using foreach to do something to an array. is there a way I can
reference a previously 'seen' element without having to traverse the array
with a for(;;) statement?
ie. I'd like this to work:
foreach(@array) {
if ($_ =~/somecondition/) {
# I want to do something to the element prior to $_ ($_ - 1)
}
}
However, I know I can use
for($x=0, $x<$#array; $x++){
if($array[$x] =~ /somecondition/){
# do something to $array[$x-1]
}
}
but I'm curious if there is a way to do the same in the foreach loop.
Thank you very much for your time.
Carl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]