http://qs1969.pair.com?node_id=324328


in reply to Re: Storing Lines before and After pattern
in thread Storing Lines before and After pattern

If there may be multiple occurrences of DOG, you want:
($before, $match, $after) = split /(DOG)/, $poem, 2;
or $after will only include up to the second DOG.