Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
No such thing as a small change
 
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 imbibing at the Monastery: (13)
As of 2014-04-16 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (418 votes), past polls