Does someone have a tool to replace one string by some other string within all files of a folder tree recursively?
(I once wrote a perl script for this, but it only functioned if I copied each file to some other destination.)


Now I just RTFM and found these beautiful scripts in the Perl Cookbook, p. 323:
##################################################
##
## Type alle the names and paths of the files within a folder tree:
##
##################################################
use File::Find;
@ARGV = qw(.) unless @ARGV;
find sub { print $File::Find::name, -d && '/', "\n" }, @ARGV;
#################### E N D ########################


and

##################################################
##
##   Find the biggest file within a folder tree:
##
##################################################
use File::Find;
@ARGV = qw(.) unless @ARGV;
my ($saved_size, $saved_name) = (-1, '');

sub biggest  {
 return unless -f && -s _ > $saved_size;
 $saved_size = -s _;
 $saved_name = $File::Find::name;
 }
find (\&biggest, @ARGV);
print "Biggest file $saved_name in @ARGV has $saved_size bytes length.\n";
#################### E N D ########################


Now again my question: Can someone add some lines, so I can do search-and-replace within each file?

TIA,
Detlef Lindenthal





Reply via email to