2009/11/2 Anant Gupta <anantgupta...@gmail.com>:
> Hello,
>
> In the foreach loop, without going to the beginning of the loop, i want to
> get the next iteration of data. How do i get it.
> eg

You can always use a for loop and refer to the next item:

for (my $i= 0; $i< @lines; $i++) {
if ($lines[$i + 1] == ...

> use strict;
> open(FILE,"<abc.txt") or die "CAnnot open";
> my @lines=<FILE>;
> foreach my $line(@lines)
> {
>     if($lin =~ m/something/)
>      {
>         #some code
>         # get next data
>         # Without going to the beginning of the loop i want to see the next
> data "$line"
>         # using "next;" takes me to the beginning
>         # is their any command or i will have to use flags
>      }
>     if(......)
>    {
>    }
> }
>



-- 
Erez

"The government forgets that George Orwell's 1984 was a warning, and
not a blueprint"
http://www.nonviolent-conflict.org/ -- http://www.whyweprotest.org/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to