Then all you need is a c-style for loop a $save scalar and a %done hash.
Similar to:
my @array = qw/ foo bar baz blah bar blah baz/; my $save = 0; my %done; for (my $x = 0; $x <= $#array; $x++) { $save = $x if ($array[$x] eq 'bar' ); print "X:$x SAVE:$save $array[$x]\n"; if ( $array[$x] eq 'blah' and !defined($done{$x}) ) { $done{$x}++; $x = $save; } }
In reply to Re: How do I backtrack while reading a file line-by-line?
by grep
in thread How do I backtrack while reading a file line-by-line?
by mdunnbass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |