I want to clarify something based on documentation from perlop:
while (my $line = <STDIN>) { print $line }
In these loop constructs, the assigned value (whether assignment is
automatic or explicit) is then tested to see whether it is defined. The
defined test avoids problems where the line has a string value that
would be treated as false by Perl; for example a "" or a "0" with no
trailing newline.
So in this case the defined test doesn't need to be done explicitly, it's already being done implicitly.