use strict; use warnings; my $pattern ='ABC'; while (<>) { last if /$pattern/; } # processing of rest of file starts here... print "printing all lines after $pattern detected!\n"; while (<>) { print; }