Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Perl RE; how to capture, and replace based on a block?

by hdb (Monsignor)
on Dec 18, 2013 at 07:29 UTC ( [id://1067600]=note: print w/replies, xml ) Need Help??


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.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1067600]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found