#!root/perl5/perlbrew/perls/perl-5.13.4/bin/perl use feature say; #empty the file `>affectedlist.txt;` #will give the list of files which contains the pattern `grep -irl "<--/--a8300-->" ./* >> affectedlist.txt`; open(FILE,"<","affectedlist.txt") or die "Couldn't open file.$!"; foreach () { chomp($_); #Change filenames to unix readable e.g Nayab Rahil to Nayab\ Rahil $_=~ s#\s+#\\ #sg; #replace the pattern on every file. s#<--/--a8300-->.*?<--/a8300-->.##isg $_; #$_ is my filename }