#!usr/bin/perl #`cp rk_7.htm rk_7.htm.bak`; #open the directory $curdir=`pwd`; print $curdir; opendir(DIR,"/home/truman/www/whistlestop/BERLIN_A") or die "couldn't"; @files= grep { /ht(m|ml)/i } readdir(DIR); foreach $files(@files){ #here make your backup $bakfile="$files".".bak"; `cp $files $bakfile`; #next open a new file to write #out the edited contents to $writetofile="$files"."temp"; open(OUT, ">$writetofile"); open(IN, "$files"); while(){ $line=$_; #substitute header and footer code for the code that works $line=~s///; $line=~s///; print OUT "$line\n"; }#end while close(OUT); close(IN); #now that the changes are written mv the new file to the old file name `mv $writetofile $files`; }#end foreach