Solved

Difference between 5.005 and 5.003 builds

Posted on 1998-10-15
2
160 Views
Last Modified: 2010-03-05
I have recently upgraded from using Activestate's Perl for Win32 (based on Perl 5.003_07) to their Active Perl (based on 5.005_02 built for MSWin32-x86-object) and have found that the loops which start with:

    while (($nextline=<INPFILE>) && ($nextline ne "EOR\n"))
    {
        # blah, blah
    }

now throw up the warning

    Value of <HANDLE> construct can be "0"; test with defined() at...

Is there anything actually wrong with the line (I have yet to have any run-time problem with the line) or is there a way to rewrite which won't throw up a warning.

Thanks

Matt Freake
0
Comment
Question by:paninaro
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1205349
1.) You're not alone; I've noticed this also, and so have (see 3b,
below) have many others.

2.) Simplest case you'll get the message on:
use strict;
my($line);
open(FIL, "somefilehere");
while($line = <FIL>) {
   yada, yada
}

will give the message as described.

3.) Two ways of getting around it:

3a.)
use strict;
my($line);
open(FIL, "somefilehere");
while(<FIL>) {
   $line = $_;
   yada, yada
}

3b.) Upgrade your perl!!! With the standard version 5.005_02, the
error goes away (I don't use the active state stuff, so I can't tell
you what the case is).  Unless you really need the object stuff, it's
probably best not to be using it in production in any case (same for
threads, IMHO)


0
 
LVL 84

Expert Comment

by:ozo
ID: 1205350
like the message says, test with defined:
  while ( defined($nextline=<INPFILE>) && ($nextline ne "EOR\n"))
(unless you actually want the loop to end if $nextline is "0")
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now