use strict; use warnings; { local $/ = undef; ### Set line terminator to nothing open(HANDLE, 'test.txt') || die; $_ = ; ### Slurp entire file } ### Match everything at or following first instance of pattern if (m/(my pattern.*)/s) { print $1; } else { print "No match found.\n"; }