Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re (tilly) 1: The easiest way to substitute a part of the content of a file.

by tilly (Archbishop)
on Jan 03, 2001 at 03:07 UTC ( [id://49415]=note: print w/replies, xml ) Need Help??


in reply to The easiest way to substitute a part of the content of a file.

For a short one-off I would recommend using the switches out of perlrun:
perl -pi.bak -e 's/content/newcontent/g' fileloc
(Use " instead of ' on Windows.)

For longer programs, you really do need to read it, manipulate a string, then write it again.

  • Comment on Re (tilly) 1: The easiest way to substitute a part of the content of a file.
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found