Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by hdb (Prior)
on Dec 18, 2013 at 07:29 UTC ( #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\>/;


Comment on Re^3: Perl RE; how to capture, and replace based on a block?
Select or Download Code
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
Node Status?
node history
Node Type: note [id://1067600]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2015-07-07 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls