in reply to Re: Re: strip out lines until match
in thread strip out lines until match

If you turned "use strict" on, you'd see the problem.

string = " blah @QUERY meaningful data meaningful data ... etc... @ENDQUERY @QUERY2 more data more data ... etc ... @ENDQUERY2"; Possible unintended interpolation of @QUERY in string at (eval 1) line + 1, <> line 16. Possible unintended interpolation of @ENDQUERY in string at (eval 1) l +ine 1, <> line 16. Possible unintended interpolation of @QUERY2 in string at (eval 1) lin +e 1, <> line 16. Possible unintended interpolation of @ENDQUERY2 in string at (eval 1) +line 1, <> line 16.

Replace the "s with 's when you initialise $string and you will see the correct result.

Also, as Enlil points out elsewhere in the thread, my regex was more complex than necessary. It can be replaced with s[\s+(\n\@QUERY)][$1]g;.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

Replies are listed 'Best First'.
Re: Re: Re: Re: strip out lines until match
by alienhuman (Pilgrim) on Apr 16, 2004 at 15:17 UTC

    Yeah, I can't believe I missed that. Just goes to show that you can't ever afford to skip "use strict", even in a simple script.

    Thanks to everyone for their help. Now if you'll excuse me, I have to go write "use strict" 1000 times on the blackboard.

    AH

    ----------
    Using perl 5.6.1 unless otherwise noted. Apache 1.3.27 unless otherwise noted. Redhat 7.1 unless otherwise noted.