Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Answer: How can I match a multi-line regexp?

( #170288=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How can I match a multi-line regexp? contributed by markjugg

If you want to do a quick in-place edit of a bunch of files, you can use this syntax:

perl -pi.bak -e 'undef $/; s/line1\nline2/new content/' files ..

This will create ".bak" files for every file it operates on. NOTE that it won't find any matches on the first line. If someone knows another one-liner that also matches on the first line, I'm interested to see it. :)

Comment on Answer: How can I match a multi-line regexp?
Download Code
Replies are listed 'Best First'.
Re: Answer: How can I match a multi-line regexp?
by Anonymous Monk on Jul 17, 2003 at 16:31 UTC
    what is the effect of undef $/; ?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-08-01 00:51 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 (285 votes), past polls