All, I know this has been asked many times, and I have read the documentation ("perldoc -q "matching over more than one line") and still can't make head or tails out of this.
I have a problem where my pattern can be in one line, or span multiple lines. This is what I have so far (simplified): #!/bin/perl use warnings; use strict; $/ = ''; my $pat = << 'EOF'; ^ AAA (.*)? ZZZ $ EOF my $file = "./mytext"; while (<DATA>) { if ( /$pat/gms ) { print "vvvvvvvvvvvvvvvvvv\n"; print "FOUND: $_"; print "^^^^^^^^^^^^^^^^^^\n"; } else { print "vvvvvvvvvvvvvvvvvv\n"; print "NOT FOUND: $_"; print "^^^^^^^^^^^^^^^^^^\n"; } } __DATA__ AAAthis is the beginning of our text and it will continue over a few lines. In case you are not sure of what you see, you should check the document yourself.ZZZ This part has nothing to do whatsoever with the above text, but to be sure, you should not see this. AAABut this single line you should seeZZZ AAABut this double line, so the question is do you see itZZZ This part you will not see. I am not sure if I can use $/ to gobble up a paragraph, since we are reading and parsing XML files, which are around 10M in size. I need to do a non-greedy pattern match. Can someone tell me what I am doing wrong please? Thanks in advance, Jeff