#!/usr/bin/perl -w
use strict;
use Futils qw( NL );
my($f) = Futils->new();
my(@opts) = qw/ --files-only --with-paths /;
my($rindir) = '../htdocs';
my($sfromfile) = './searchpat';
my($rfromfile) = './replacewith';
my($rstr) = $f->load_file($rfromfile);
my($spat) = quotemeta($f->load_file($sfromfile)); $spat = qr/$spat/;
my(@files) = $f->list_dir($rindir, @opts);
foreach (@files) {
print(q[Skipped binary file ] . $_ . NL) and next if $f->isbin($_);
my($sbt) = 0;
my($file) = $f->load_file($_);
$file =~ s/$spat/++$sbt;$rstr/ge;
$f->write_file('file' => $_, 'content' => $file);
print(qq[$sbt substitutions in $_] . NL);
}
print(q[Done.] . NL . NL);