#!/bin/perl5.8.6 use warnings; use diagnostics; use File::Basename; @files = <../tryremove/*>; #This is the destination path where the comment removed files are created. $path1 = "C:/Projects/tryremove/c"; foreach my $file (@files) { my $filename =basename($file); open(file1,"$file") or die "The file cannot be opened the $file:$!\n"; open(file2,">$path1/$filename") or die "The file cannot be opened:$!\n"; while(!eof(file1)){ $/ = undef; $_ = ; s# .* report [s]? .* ; .* ##sx; print file2 ($_); } close(file1); close(file2); }