while (<>) { my_sub() if $. > $allowedlines; print; # do the rest of your stuff }