in reply to Re: Detect Two Strings in File
in thread Detect Two Strings in File
Let me test through a few scenarios and see if I can clarify further.
After testing your solution here this does indeed seem to be on the right track. It grabbed the last string1 found and then alerted when it found string2. Oddly enough string2 was found on two different lines, but it detected it on the 2nd line, not the first found.
Testing to see if it can be tailored to also detect if on same line
UPDATE - Looks like we can add this condition if it appears on the same line by adding this condition in the failure part:
So this SHOULD work. Thanks again for the assistanceif ($first_pos == $second_pos) { print "Success! (STRING: $first_pos matches same line as MAGIC : $ +second_pos)"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Detect Two Strings in File
by CountZero (Bishop) on Nov 07, 2014 at 05:03 UTC |