Doozer has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I need help adjusting a foreach loop in a current script to start reading a file from a specific line. I have a script that reads each line in a text file and does a get request on each line (each line is a website hostname). The file lists 1 million hostnames so it is a BIG file.
I had my script running for nearly 2 weeks now and it had got to line 209,848 before I played with CPAN and accidentally stopped the script! This is some pretty important testing I am doing for work so I need to get it back up and running from the last line it got to in the file.
My code for the foreach loop is as follows:
I would really appreciate some help as I have looked online but cant find anything that matches my current method. I would like to tweak the current as little as possible.open SOURCE, "</path/to/my/file.txt"; my @lines = <SOURCE>; foreach my $line (@lines) { #Do the get request magic; }
Thanks in advance!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Foreach loop help. Start from specific line
by Corion (Patriarch) on Oct 22, 2012 at 12:47 UTC | |
Re: Foreach loop help. Start from specific line
by blue_cowdawg (Monsignor) on Oct 22, 2012 at 13:04 UTC | |
Re: Foreach loop help. Start from specific line
by roboticus (Chancellor) on Oct 22, 2012 at 13:27 UTC | |
Re: Foreach loop help. Start from specific line
by 2teez (Vicar) on Oct 22, 2012 at 13:06 UTC | |
Re: Foreach loop help. Start from specific line
by sundialsvc4 (Abbot) on Oct 22, 2012 at 13:42 UTC | |
by Doozer (Scribe) on Oct 22, 2012 at 14:18 UTC | |
Re: Foreach loop help. Start from specific line
by parv (Parson) on Oct 22, 2012 at 13:28 UTC | |
Re: Foreach loop help. Start from specific line
by aitap (Curate) on Oct 22, 2012 at 15:47 UTC | |
Re: Foreach loop help. Start from specific line
by Doozer (Scribe) on Oct 22, 2012 at 13:21 UTC |
Back to
Seekers of Perl Wisdom