a word about the power of unix shell commands: perl one liners, i.e. one line of perl that can save you hours of error-prone hand changes. when i want to do some massive changes in my code this is what i use.
say you need replcae a record name from abc_record to xyz_record, first if you use perl recursivlly it will touch all files and revision control will makr them for commit. you don’t want that. so use grep to filter the relevant files:
grep "#abc_record\b" . -rl
next, do the replace:
perl -i -pe s/"#abc_record\b"/"xyz_record"/g `grep "#abc_record\b" src -rl`
note the use of \b to mark a word boundary.
a more complex replace is if you need to change the code from using a record to use a wrapper function. so for exmaple we have the record:
and we want to start use a wrapper module:
-module(rtools). -export([fld/1]). fld(R) -> R#abc_record.fld.
so we can do it instantly like that:
perl -i -pe s/"\b(\w+)#abc_record\.fld"/"rtools:fld(\1)"/g `grep "#abc_record\.fld" src -rl`
here we have switched from using A#abc_record.fld to record_tools:fld(A)
another trick is to remove complete lines (!), so for exmaple you can get rid of all the -compile(export_all) you have fullishly inserted into your code:
perl -i -nle 'print if !/-compile\(export_all\)/' `grep export_all src -rl`
one safty tip, omit the -i first to try before you actuall change files.
this was just a learn-by-example, more info can be found at: