I have code that captures “between” some text; in particular, between a foo $somewordand the following foo $someword.
However, what happens is that it gets stuck in the first “between,” and somehow the internal position of the line does not increase.
The input is a text file with new characters here and there: they are irrelevant, but make printing easier.
my $component = qr'foo (\w+?)\s*?{';
while($text =~ /$component/sg)
{
push @baz, $1;
}
my $list = join( "|", @baz);
my $re = qr/$list/;
while($text=~/($re)(.+?)foo ($re|\z|\Z)/ms)
{
print $1, ":", $2;
print "\n", '-' x 20, "\n";
}
source
share