Revision a10c039e04faa11fa528b5dc1e1630bbd8eb7393 authored by Nathan Nutter on 08 January 2013, 20:24:39 UTC, committed by Nathan Nutter on 08 January 2013, 20:24:39 UTC
If an observer is set on a class name then it would receive undef as the first argument instead of the (sub)class name. This should allow that to be passed along.
1 parent fa55792
findreplace
#!/usr/bin/env perl
use strict;
use warnings;
my $find = shift;
my $replace = shift;
my @files = @ARGV;
unless (@files) {
@files = <STDIN>;
}
chomp(@files);
for my $file (@files) {
next if (-d $file);
next if ($file =~ /.bak\d+/);
print "Handling $file\n";
my $bak = $file . ".bak$$";
print `mv '$file' '$bak'`;
print `grep -- '$find' '$bak'`;
#print `cat $bak | sed 's/$find/$replace/g' > $file`;
my $IN;
my $OUT;
open($IN,$bak) or warn "can't open $bak!" && next;
open($OUT,">$file") or die;
while (<$IN>)
{
$_ =~ s/$find/$replace/g;
print $OUT $_;
}
close $OUT;
close $IN;
print `diff $bak $file`;
print `rm $bak`;
print "\n";
}
#print "\\rm `find * | grep .bak$$\n";
Computing file changes ...