#### #### #!/usr/bin/perl #the path to the files $serverpath = "/default/main/test"; #the docs you want changed $doctype = "html"; #the string to look for $find = "/exitPage/index.jsp?"; #what you want to replace it with $replace = "javascript:flexWin('"; #ok, getting started print "Finding \"$find\" and replacing it with \"$replace\"\n"; #going to directory opendir(DIR, "$serverpath"); #looking for files @files = grep(/\.$doctype$/,readdir(DIR)); closedir(DIR); #lining the files up foreach $file(@files){ $pa_fi = "$serverpath/$file"; #opening the file to read it print "opening file $pa_fi\n"; open(FILE,"$pa_fi"); my(@subm) = ; close(FILE); #backup the document rename $pa_fi, $pa_fi . '.bac'; print "making backup\n"; $n=0; #printing new foreach $line (@subm) { $line =~ s/$find/$replace/g; open(SUB,">>$pa_fi"); print SUB $line; close(SUB); $n++; } print "$n lines searched in $file\n"; }