l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2001 Dec 30 16:59

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] PERL error message: Value of <HANDLE> construct canbe "0"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] PERL error message: Value of <HANDLE> construct canbe "0"

  • Subject: Re: [vox-tech] PERL error message: Value of <HANDLE> construct canbe "0"
  • From: Matt Roper <mdroper@MAPSucdavis.edu>
  • Date: Mon, 08 Jan 2001 16:49:27 -0800
  • References: Pine.GSO.4.21.0101081628370.22460-100000@logan.ucdavis.edu

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 Roper

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.

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.