in reply to Re^2: Perl RE; how to capture, and replace based on a block?
in thread Perl RE; how to capture, and replace based on a block?

Hi Chris, specifying a regex on the command line seems a difficult thing to do. At least you should be printing your $regexp to see what it contains.

In any case, this code seems to work:

my $str = " </div> </body> "; print "Success\n" if $str =~ /\<\/div\>\n\<\/body\>/;

which suggests that if you slurp in your whole file as a single string (e.g. by unsetting $/), your regex should do its job.

local $/; my $str = <>; print "Success\n" if $str =~ /\<\/div\>\n\<\/body\>/;

Replies are listed 'Best First'.
Re^4: Perl RE; how to capture, and replace based on a block?
by taint (Chaplain) on Dec 18, 2013 at 07:51 UTC
    Perl said; Success.

    Thanks a million, hdb! Your suggestion has helped me greatly in putting the last piece in my current "puzzle".

    Thanks again. I'd like to buy a round of +'s, for the house.

    --Chris

    UPDATE; I forgot to mention. The reason I was feeding the file to Perl is
    1) That's what worked best for me with sed.
    2) It seemed the easiest way to experiment getting a correct match with Perl.
    Yes. What say about me, is true.