Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why are lines being skipped in output?

by halley (Prior)
on Mar 18, 2008 at 16:37 UTC ( #674829=note: print w/ replies, xml ) Need Help??


in reply to Why are lines being skipped in output?

By way of insight (or explanation): the while statement has some magic to do common tasks like this without stating everything specifically.

while (<FOO>) { ... }
seems to a newcomer like it would mean
while (not_the_end_of_the_file(*FOO)) { ... }
but in actuality it means
while (defined ($_ = readline(*FOO))) { ... }
So it does both tasks at once: breaks the loop at the end of the file, AND reads the next line into the default variable $_.

--
[ e d @ h a l l e y . c c ]


Comment on Re: Why are lines being skipped in output?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2015-07-07 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls