# this is a slice, probably not intended
@someList[0] = 'foo';
####
@someList[0] better written as $someList[0]
##
##
#!/usr/bin/perl -w #alternative warning syntax
use strict;
use File::Find;
#########################################################
# a debugging variable
#########################################################
my $totalChanges;
my @dirs = qw(.);
find ( { wanted => \&change, no_chdir => 1}, @dirs );
sub change
{
my $file = $File::Find::name;
if ( -f $file && $file =~ /\.html$/ )
{
###################################
# debugging print statement
###################################
print "going into $file\n";
my $buffer;
open(IN, $file) or warn "CAN'T OPEN $file!\n";
{
local $/ = undef;
$buffer = ();
}
close IN;
my $changecount = ($buffer =~ s/FOO/BAR/gi);
if ($changecount)
{
#######################################
# increment debug variable
#######################################
$totalChanges++;
#######################################
# debugging statement
#######################################
print "changed $changecount instances in $file\n";
open(OPF,">$file") or warn "NOT OPENING $file FOR MOD, $!\n";
print OPF "$buffer";
close OPF;
}
}
}
###################################################
# debugging statement
###################################################
print "$totalChanges files changed\n";