Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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


Comment on Re: multi-line in-place edits
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://431297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2016-02-12 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (402 votes), past polls