Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 ]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://674829]
[LanX]: scalar grep {$_ ==1 } keys %hash
[ovedpo15]: maybe even better question is if it possible to pash element to array from left. I mean that the element will enter array[0] and all other elements will move right +1

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2018-03-24 21:21 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.