Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-05-05 00:34 GMT
Find Nodes?
    Voting Booth?