You need to use a for loop for this.
----- Original Message -----
From: "Ken Lehman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 22, 2002 3:42 PM
Subject: howto: array index inside a foreach loop


> Say I have a foreach loop that I used to modify elements when they match a
> pattern that I am searching for, but there is one special case where I get
a
> match and I need the index for that element. Can I get that index or do I
> have to go with a for() loop. If this can be done how would I use it?
> Thanks in advance
> Ken
>
>
> # something along these lines
> foreach $temp_string (@array_of_strings)
> {
>  if ($temp_string =~  /^CRASH/)
>  {
>    $array_of_strings[$this_is_what_I_need - 1] = "LOOK OUT!";
>  }
>
>
> }
>
> --------------------------------------------------------------------------
--
> --------------------
> The views and opinions expressed in this email message are the sender's
> own, and do not necessarily represent the views and opinions of Summit
> Systems Inc.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to