What this message is warning about is that it is theoretically possible
for your line of code
$line = <MAIL>
to read a just 0 or empty value somewhere in the middle of the file. In
such a situation, your loop condition would evaluate to false and your
loop would stop before you had read all the lines of the file. Usually
the newline character (\n) would save you from this situation since the
newline always evaluate to true, but I think this can be a problem if you
modify some of perl's special status variables.
Anyway, what perl is suggesting you do is write the line like this:
while(defined($line = <MAIL>)) {
This set the value of $line, but will also always evaluate to true unless
you hit the end of the file since defined($var) is true even if $var is
set to a false value.
Hope that makes sense...
Matt
=========================
Matt Roper
[EMAIL PROTECTED]
http://www.mattrope.com
=========================
On Mon, 8 Jan 2001, Mark Kim wrote:
> I got this PERL error message. Can someone explain what it means?:
>
> Value of <HANDLE> construct can be "0"; test with defined() at ./check
> line 65535.
>
> My program "./check" is not 65535 lines long. I don't use a variable
> named "HANDLE", although I do open a file called "MAIL" and I read <MAIL>
> like this:
>
> while($line = <MAIL>) {
> ...
> }
>
> Thanks! (Side remark: If some con struct _can_be_"0"_, why is it
> complaining? I'd expect it to complain if it *can't* do something.) BTW,
> the message does go away if I remove the -w option, and whether I use the
> -w option or not, the program works as expected. I just want to know why
> I'm getting the message...
>
> -Mark
>
> ---
> Mark K. Kim
> http://www.cbreak.org/mark/
> PGP key available upon request.
>