use strict; my $files = "/perl/bin/ThisDirectoryHere"; opendir(DIR,$files) || die "Can not open directory: $!"; my @files = grep(!/^\.+$/, readdir(DIR)); close(DIR); my $ct = 0; #I need to open each file and change oldword to newword for(@files) { #Read File open(IN, "$files/$_") || die "Can't open $_: $!\n"; my @lines = map {$ct += s/oldword/newword/gi;$_} <IN>; close(IN); #Write File open(OUT, ">$files/$_"); print OUT @lines; close(OUT) } print "\nTotal Changes = $ct\n";
In reply to Re: Changing data in one directory
by tcf22
in thread Changing data in one directory
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |