Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: errors

by autark (Friar)
on Feb 02, 2001 at 02:56 UTC ( #55892=note: print w/replies, xml ) Need Help??


in reply to errors

perl is complaining about your while-test. You have to test with defined, like this: while( defined($_ = <>) && $_ ne "quit\n" ) {} The reason, as stated in the error message, is because the <> may generate a "0", and that would evaluate to false. With defined however, it will evaluate to true.

Newer perls usually puts the defined() around any such simple constructs as $_ = <SOME_HANDLE>. (within a while). Take this as an example:

perl -MO=Deparse -le 'while($_ = <>) {}' -e syntax OK while (defined($_ = <ARGV>)) { (); }
However, this is not done with more complicated constructs such as yours.

Autark.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://55892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2020-12-06 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?