Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: multi-line in-place edits

by cog (Parson)
on Feb 15, 2005 at 19:05 UTC ( #431297=note: print w/replies, xml ) Need Help??


in reply to multi-line in-place edits

This works:

perl -pi -e 'BEGIN{undef$/};s/(.*)/<$1>/s' filename.txt

A couple of notes:

  • Use $1 instead of \1 (use \1 only in the left part of the substitution
  • The /g switch fell off (you only wanted to do it once)

And... I guess that's it... I undefined $/ so that the file would be read all at once :-)

HTH

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://431297]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-05-24 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?