Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 ( #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
Node Status?
node history
Node Type: note [id://1067600]
help
Chatterbox?
[erix]: heh

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2017-11-22 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (316 votes). Check out past polls.

    Notices?