MiriamH has asked for the wisdom of the Perl Monks concerning the following question:
There are 15+ event titles that I want to capture. The event titles are always written between the words "summary" and "description". I indexed the words summary and description and then began printing out what was between the indexes, however I have been putting the index 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 " <$fragment>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Automatic Subsequent Indexing.
by muba (Priest) on Jun 22, 2012 at 15:28 UTC | |
by MiriamH (Novice) on Jun 22, 2012 at 16:07 UTC | |
|
Re: Automatic Subsequent Indexing.
by Anonymous Monk on Jun 22, 2012 at 15:14 UTC |