[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] File Handle Error in New MacPerl



At 14.41 1/1/98, Richard Rathe wrote:
>I downloaded the new MacPerl and suddenly I see this error message in
>several of my scripts:
>
>  # Value of <HANDLE> construct can be "0"; test with defined().
>  File ':mtxextra.pl'; Line 113

>    while($line = <IMAGES>) {          <--- Line 113

>I tried to look up this warning in the Camel book but it doesn't seem to be
>there. Can anyone tell me what I'm doing wrong? I thought 'while($line =
><IMAGES>)' was a legitimate way to read a file a line at a time until the
>end. I am using the -w flag.

You thought wrong.  :)

That error should have been present in MacPerl 5.1.5 and others based on
5.004, too.  What was determined was that the $line = <IMAGES> construct
can sometimes return FALSE even when the file is not done.

However, I do not think it is possible that this could happen as long as
your input record separator ($/) is not changed (because a newline will
always be in $line).  But if your input record separator has been changed,
then $line could contain a false value even when the file is not done.

So, the proper way to do it is:

    while(defined($line = <IMAGES>)) {

But if you don't muck with $/, you should be OK regardless and you can
likely safely ignore the error.

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch