$s = "this is a load of junk to be consumed until we get to the word stop. After that nothing should stop it until another stop";; print $1 while $s =~ m[(.+?)stop]g;; this is a load of junk to be consumed until we get to the word . After that nothing should it until another