use File::Copy; use strict; use warnings; $dirpath="C:\\inetpub\\performancetesting\\output\\new\\mlx\\aar"; $dirpath2="c:\\temp"; opendir(IN,"$dirpath") or die "opening directory failed:$!"; while (defined ($file = readdir(IN)) ) { @files=split / /,$file; foreach $filename (@files) { Copy (INPUT, "$dirpath".$filename, "$dirpath2".$filename) or warn "Can't open the file yet $filename\n:$!"; until (eof(INPUT)) { chomp($line = ); # print contents of the file or do anything print "$line"; } } } closedir(IN);