$ cat gah.pl use strict; use warnings; my $t = "The quick red fox jumped over the lazy brown dog."; if ($t =~ /(jump)/g) { print "Found $1 ending at ", pos($t), ".\n"; } if ($t =~ /(\w+)\s+(\w+)\G/) { print "Found <$1> before <$2>\n"; } $t = <\n"; } } $ perl gah.pl Found jump ending at 22. Found before Found weird