jclh has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I need to step through a web page one line at a time, and once I match a string, grab the next N lines...
My first thought was to load the content of the page into an array and each line would be an element:
$browser->get( $url ); my @array = $browser->content; print scalar @array;
The problem is, that loads the whole page into a single array element not allowing me to do this:
while($Element=shift(@array)) { if($Element =~ m/SomeonesName/) { print "$Element\n"; } }
So, my question is: what is the best way to step through the page one line at a time?
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to step through a web page with WWW::Mechanize one line at a time
by Corion (Patriarch) on Jun 04, 2013 at 07:06 UTC | |
|
Re: Trying to step through a web page with WWW::Mechanize one line at a time
by hdb (Monsignor) on Jun 04, 2013 at 08:08 UTC | |
by jclh (Initiate) on Jun 05, 2013 at 01:32 UTC |