Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Foreach Loop in Data Scraping

by MiriamH (Novice)
on Jun 22, 2012 at 14:10 UTC ( [id://977851]=note: print w/replies, xml ) Need Help??


in reply to Re: Foreach Loop in Data Scraping
in thread Foreach Loop in Data Scraping

I did what you said, but it only gave me the first event, however there are 15+ events that I want to capture. I indexed the words summary and description and then began printing out what is between the indexes, however I am putting the numbers in manually each time. Is there a way for Perl to automatically go to the next index? (Instead of $My Sum1 and $My Sum2 being specific numbers)
my $substr = 'SUMMARY'; my $offset = 0; my $result = index($string, $substr, $offset); while ($result != -1) { print "$result\n"; $offset = $result + 1; $result = index($string, $substr, $offset);} my $SUM1= "298"; my $SUM2="877"; my $length = $SUM2-$SUM1; my $fragment = substr $string, 298, $length; #print " string: <$string>\n"; print " <$fragment>\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-23 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found