In PERL Does anyone know how to print after you did a search, for the line after the word it.?

For instacne I searched for a period. It is found in the line "….is in 1996"." (this line is followed by) After that it was happily feeding modules through CPAN."

I need to print out the part after the word it , i.e was happily feeding modules through CPAN.

So again I searched for the match of a period. And after that I am to print the next line after that period, starting after the word it.
Hey Jake this is what I have so far.

open(AFILE, $ARGV[0]);

while(<AFILE>){
$string .= $_;
}
if($string =~ /\.|\?|,/){
print $string;
}else{
print "no match";
}

I tried doing the way your were saying and using the:
@wordsAfterPeriods = $sentence =~ /(?<=\. *)\w+/g
but I was getting a compilation error with this.
How can I fit this @ wordsAfterPeriods into what I have so far?

Thanks again for helping me!


Related Blogs

Comments

  1. jake cigar™ is retired says:

    $sentences = "the dog ate my homework. now is the time for all good programmers to take it to the limit.";

    @wordsAfterPeriods = $sentence =~ /(?<=\. *)\w+/g;

    print @wordsAfterPeriods;

    it’s kind of magic! if there are words after periods , it prints them otherwise it prints nothing!

    you could add
    print "nothing" unless length @wordsAfterPeriods;

legitimate work from home jobs | Event Planning Bay Area | rent video games | Homeloans | Plumbing Courses in Manchester | increase fertility | Green Drink | Photo Keyring | Vitamin D Deficiency Symptoms | skip bags | Order Fulfillment Software | virtual receptionist | Educators Credit | bodybuilding workouts | window cleaning
Poker Software