my @good_stuff = $stuff =~ /^START\n(.*?)^END$/gms; # or alternatively with START and END around my @good_stuff = $stuff =~ /(^START$.*?^END$)/gms; #### $stuff = << EOF; blah START a few lines END lots of lots of lines EOF #### $stuff = << EOF; blah START lots of lots of lines END blah EOF