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