##
#!/usr/bin/perl -w
use strict;
my $string = "fooAbar" .
"fooBbar" .
"gooCbar" .
"fooDfooEbar" .
"foo";
while ($string =~ m/\G.*?foo(.*?)bar/g) {
print $1, "\n";
};
##
##
H:\>perl -w test.pl
A
B
DfooE