l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social Gathering
Next Installfest:
TBA
Latest News:
Nov. 18: Officers elected
Page last updated:
2001 Dec 30 16:59
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat (IRC)
 Social Networks
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


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


=========================
Matt Roper
mdroper@ucdavis.edu
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.
>


LinkedIn
LUGOD Group on LinkedIn
facebook
LUGOD Group 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
1105 Kennedy Place, Suite 1, Davis, CA 95616
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:
California Computer News
Who donated books and ad space.