undef $/; $current = ; $start = ''; $end = ''; my ($match) = $current =~ m/$start(.*)$end/s; print $match; __DATA__ stuff i don't want stuff i do want more stuff i don't want #### my ($match) = $current =~ m/$start(.*)$end/s; # note the parens around $match #### $match =~ tr/\n//d; # or $match =~ s/\n//g;