http://www.perlmonks.org?node_id=981169


in reply to Re^2: Split words
in thread Split words

Nice observation!
However, for repeating "monks" all we need is this:
while($line=<DATA>) { while($line=~m/monks/g) { print "\n==>$`\nmonks\n$'"; } }
Now I've assumed prefix of "monks" means whatever precedes "monks" in the string (even if it contains previous "monks") Same goes for postfix.