in reply to Finding number of lines in STDIN
while(<>) { last if $number_of_lines && $. > $number_of_lines; ... } [download]