DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Search and replace across files using perl


How can I use perl's powerful string functions to do a search and replace across all files in a directory?


Use perl from the command line as shown below.

On an MSDOS/ Windows system you may get the error message

Can't do inplace edit without backup
In this case use the second variation, which tells perl to create a .bak backup file.

// at the shell command line
 // search and replace in all C++ files
 perl -pi -e 's/searchterm/replaceterm/' *.cpp
 perl -pi -i.bak -e 's/searchterm/replaceterm/' *.cpp

Generated 0:02:11 on Jan 23, 2019