$x = 'the quick brown fox jumps over the lazy fox';; print "<$1>" while $x =~ m[(......fox)]g;; < lazy fox> print "<$1>" while $x =~ m[(......fox)(?!$)]g;;