@allmatches = $text =~ m/foo(.*?)bar/g; for ( @allmatches ) { print "dollarunderscore= $_ \tdollarone= $1\n"; } #### while ($text =~ m/foo(.*?)bar/g) { print "dollarunderscore= $_ \tdollarone= $1\n"; } #### $text =~ m/foo(.*?)bar/g; print "$_ \t$1\n"; $text =~ m/foo(.*?)bar/g; print "$_ \t$1\n"; $text =~ m/foo(.*?)bar/g; print "$_ \t$1\n"; #[... repeated as often as necessary ...]