Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: uninitialized value $_

by Marshall (Canon)
on Mar 28, 2016 at 22:26 UTC ( [id://1158982]=note: print w/replies, xml ) Need Help??


in reply to Re^4: uninitialized value $_
in thread uninitialized value $_

Perhaps a better thought model is that $_ gets assigned the last thing read. At the end of the file, that last thing is the EOF, which is returned as undef.

The fundamental problem here was poor loop design. The use of for(;;){} or while (1){} should be restricted to very special circumstances like an infinite loop in server code to wait for next connection, etc. If the loop is coded differently and I would argue properly, as corion suggests, while (<>){}, this handling undef inside the loop problem goes away.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found