Not really a MacPerl question... but since I have something better to do :-) At 3:07 pm +0100 28/7/98, William B. Birkett wrote: >When I run a program containing the following lines, > > while ($line = <IN_FILE>) { > print $line; > } > >I get the following warning, > ># Value of <HANDLE> construct can be "0"; test with defined(). >File 'Untitled'; Line 10 > >The reason I am using $line is that I have another file opened and don't >want to alter the $_ variable. This construct is in the MacPerl P&E book, >so I assume it is commonly used. > >The program executes properly, but I am bothered by the warning. What does >the warning mean? Is there a better way to write this code? > > >William B. Birkett Imagine IN_FILE consists of the following 5\r 4\r 3\r 2\r 1\r 0 Now, since the last line doesn't have an end-of-line character $line will equal "0" which equates to false, so it doesn't get printed. Probably not what you wanted to happen. Just do something like while (defined($line = <IN_FILE>)) { print $line; } to get the "correct" behaviour. Hopefully this makes sense :-) Cheers, Adrian >Precision Color, Inc. >9200 General Drive >Plymouth, MI 48170 (USA) > >Phone: (734) 459-5640 >FAX: (734) 459-4210 > > > > >***** Want to unsubscribe from this list? >***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch ---- Adrian Howard. adrianh@victoriareal.co.uk. Head Techie. Victoria Real Ltd URL: http://www.victoriareal.co.uk/ v. +44 1273 774469 f. +44 1273 779960 ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch