Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
laziness, impatience, and hubris
 
PerlMonks  

Re: (Challenge)(for new users) Replacing a text

by Random_Walk (Prior)
on Sep 24, 2004 at 08:18 UTC ( [id://393474]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to (Challenge)(for new users) Replacing a text

If the phrase split across a line break does not count then it is easy. If it does count then it is rather hard to do in a one liner without being clunky..

# No worries about line breaks perl -i -pe's/Will Emigh/YAPH Emigh/g' # line breaks concern me but STDOUT will do perl -pe'$a.=$_}{$_=$a;s/Will(\n*) (\n*)Emigh/YAPH\1 \2Emigh/g' # line break concern me and lets put it back in the file perl -ne'BEGIN{$f=$ARGV[0]}$a.=$_}{$_=$a;s/Will(\n*) (\n*)Emigh/YAPH\1 + \2Emigh/g;open F,">$f";print F $_'
Of course the last only works with one input file, and I got so worried about line breaks I forgot to make it short. (cunning tachyon)

Cheers,
R.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://393474]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.