my $first; while () { s/\s+$//; # strip newline and whitespace from end of line if( ! $first++) { print "The first line is '$_'\n"; next; }; print "Some other line is '$_'\n"; };