Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: search and replace text in multiple files in a directory

by steelrose (Scribe)
on Apr 04, 2005 at 15:03 UTC ( #444707=note: print w/ replies, xml ) Need Help??


in reply to search and replace text in multiple files in a directory

It really depends on whether you want to actually open each file in the perl program itself, or let the OS do that for you. I do something similiar to the latter, where I make a system call: system ("sed 's/$searchString/$replacementString/g $filename > $newFilename'"); Note that I'm creating a NEW file with the changed text and not overwriting the original.

If you give a man a fish he will eat for a day. If you teach a man to fish he will buy an ugly hat. If you talk about fish to a starving man, you're a consultant.


Comment on Re: search and replace text in multiple files in a directory

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-11-29 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls