Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 chanting in the Monastery: (5)
As of 2015-08-01 02: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