in reply to $1 doesn't reset?
perlre tells us to use the \G anchor :
while ($res->content =~ m/\G.*?foo(.*?)bar/g) { print "$_ - $1\n"; };
Maybe you'll want to read Death to Dot Star! before you use .*?, but unless we know more about the data, .*? will have to do ;-)
Update: If I run this program :
#!/usr/bin/perl -w use strict; my $string = "fooAbar" . "fooBbar" . "gooCbar" . "fooDfooEbar" . "foo"; while ($string =~ m/\G.*?foo(.*?)bar/g) { print $1, "\n"; };
I get the following, expected output :
H:\>perl -w test.pl A B DfooE
I guess the error lies somewhere else in your regular expression then - maybe post the whole RE together with some sample data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: $1 doesn't reset?
by alfie (Pilgrim) on Mar 20, 2001 at 15:54 UTC | |
by andye (Curate) on Mar 20, 2001 at 17:56 UTC |