in reply to Multiple strings in a file

> matching more than 2 strings across multiple lines

I'm not sure which question you are asking, but think you are looking for the flip-flop operator

try

open my $text, "<", $textFile>" or die "Dead"; while(<$text>){ if(/$firstString/ .. /$secondString/){ print $_; } }

otherwise please show desired input and output.

Cheers Rolf

PS: Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Multiple strings in a file
by The_Last_Monk (Novice) on Feb 10, 2015 at 17:55 UTC
    Ok so lets say my text file has the following sentences
    Transformers robots in disguise I whip my hair back and forth I will catch a dog with a trap
    Now lets say, ignoring the case, the first word i want to look for is Trap, and the second word i want to look for is Hair. Basically it should print
    I will catch a dog with a trap i whip my hair back and forth
    Is that more clear? Sorry for not making it clear before.
      > Is that more clear?

      no because your code should already do this, if you don't want double matches follow toolic's advice.

      Cheers Rolf

      PS: Je suis Charlie!

        I did, the problem that i am having testing locally is that it doesn't seem to recognize that there are more than 2 lines. So if the word i want is within the first 2 lines, it will print it, but if i want to print a word from the 3rd line, it won't