Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Help with for loop

by BrowserUk (Pope)
on Sep 12, 2013 at 02:22 UTC ( #1053638=note: print w/ replies, xml ) Need Help??


in reply to Help with for loop

What am I doing wrong?

You are expecting to be able to re-read your file each time you iterate your for loop. But that is not how IO works (in any language).

Files read from beginning to end and then stop.

If you want to re-read your file each time around your for loop, you will need to either:

  • Re-open the file each time.

    Ie. put the open & close inside the for loop.

  • Or "rewind" the file each time you iterate the for loop.

    Ie. Add a line: seek NB_FILE, 0, 0; as the first line inside the for loop.

    See seek() for details.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Help with for loop
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2014-11-23 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (128 votes), past polls