#!/usr/bin/perl use File::Find; @ARGV = ('.') unless @ARGV; $dir = shift @ARGV; find( \&edits, $dir ); sub edits() { return unless -f; #skip directories $seen = 0; $file = $_; #Uncomment next line if you want multi-line edits #undef $/; local $^I = ".backup"; #Warning - heavy magic here local @ARGV = ($file); while (<>) { #Remember to use the s option if doing multiline edits $seen++ if s/Lesson/Chapter/; print; } print "Found in $File::Find::name\n" if $seen > 0; #Comment out if you want to keep the backup #unlink $file.".backup"; }