in reply to Foreach Loop in Data Scraping

MiriamH, I think you just want to display all the titles through regular expression, so to find out multiple data you should use while/foreach loop. For this I'll go for while loop, try your code this way:
while($string=~m/SUMMARY(.*?)DESCRIPTION/gi){ print 'Summary: ',$1; ## prints title of event }
Let me know if you face any problem after this also

Replies are listed 'Best First'.
Re^2: Foreach Loop in Data Scraping
by MiriamH (Novice) on Jun 22, 2012 at 14:10 UTC
    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";