Brilliant! Thanks, no more warnings :-)

Ela

> -----Ursprüngliche Nachricht-----
> Von: Michael Fowler [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 29. Juni 2001 19:20
> An: Ela Jarecka
> Cc: Beginners list (E-Mail)
> Betreff: Re: short filehandle question
> 
> 
> On Fri, Jun 29, 2001 at 02:28:50PM +0200, Ela Jarecka wrote:
> > Hi,
> > Executing my program with -w option I get the following warning:
> > 'Value of <HANDLE> construct can be "0"; test with 
> defined() at readData
> > line 65535.'
> > 
> > Surely I do not have 65535 lines in my program, but I 
> suspect this one:
> > 
> > #reading data
> > open (FILEH, $filename) or die "Can't open file!\n";
> > 
> > while ($line = <FILEH>) {
> > ....
> 
> I have no idea where the others are going with their lexical 
> vs. non-lexical
> filehandle, so you should probably disregard that avenue.
> 
> Your problem is probably in that area.  Specifically, it's 
> likely while
> loop.  Your intent is to read until EOF, but it will fail if 
> <FILEH> returns
> just 0, which it can if the last line in the file contains 
> only a 0 and no
> trailing newline.
> 
> You need to test for defined'ness, not truth:
> 
>     while (defined($line = <FILEH>)) {
>         ...
>     }
> 
> The error message you describe is in perldoc perldiag.  More 
> recent versions
> will actually turn your loop form into the loop form above 
> (checking for
> defined'ness).  What this means is that if you're using a more recent
> version (at the least, 5.004 and beyond) your problem lies 
> elsewhere, in one
> of the other constructs listed in the perldiag entry.
> 
> 
> Michael
> --
> Administrator                      www.shoebox.net
> Programmer, System Administrator   www.gallanttech.com
> --
> 

Reply via email to