in reply to Replacing one string within a file with another string

This is difficult to make efficient, simply because you have to read in the full contents of every file to perform the replacement operation. Not to mention that you might wind up replacing the wrong thing! Here are some guidlines you can use to get you started, at least:

  1. Use File::Find to get a list of files. This verily automates the process of recursing through a directory tree and extracting a specific list of filenames. You can even read this for an example I wrote earlier today.
  2. Use `local()' to modify the value of $/ (the input line separator), ala local($/) = undef. This will allow you to slurp in a whole file into a scalar, then you can `study()' that scalar, perform a regex, and dump it back out to a file.
  3. Make backups. All the decent "Cross-File Find & Replace" engines at least give you the options of making backups. A simple system('cp', $filename, $filename .".bak") should do the trick.
  4. Good luck!

    Alakaboo