my @good_stuff = $stuff =~ /^START\n(.*?)^END$/gms; # or alternatively with START and END around my @good_stuff = $stuff =~ /(^START$.*?^END$)/gms;