CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Drinc3] open and close file before each while-looping through file?: Edit Log



FishMonger
Veteran / Moderator

Sep 12, 2013, 10:17 AM


Views: 1523
Re: [Drinc3] open and close file before each while-looping through file?


Quote
EDIT: Why isn't the code properly formatted?

You need to use the code tags, which is the button at the bottom-left of the input text box.

After the first while loop the filepointer is positioned at the end of the file. If you want to loop over the contents a second time, you need to either use the seek function to reset the file pointer, or close and reopen the file. Between these 2 options, using seek would be better.

However, a better option would be to rework your logic and only loop over the file once.


(This post was edited by FishMonger on Sep 12, 2013, 10:17 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Sep 12, 2013, 10:17 AM
Post edited by FishMonger (Veteran) on Sep 12, 2013, 10:17 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives