Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 taking refuge in the Monastery: (17)
As of 2015-07-06 11:47 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 (73 votes), past polls