DaWolf has asked for the wisdom of the Perl Monks concerning the following question:
Well, in dir1 I have two files: abc.xls and abd.xls When I run the app it copies only the first file (abc.xls)! If I replace the exec() line for a simple print it works perfectly...#!/usr/bin/perl -w use strict; my $path1 = "C:\\foo\\dir1"; my $path2 = "C:\\foo\\dir2"; opendir DIR, $path1 || die "\n\nUnable to open $path1. Error: $!\n\n"; my @files = readdir DIR; closedir DIR; for (my $f = 0; $f < scalar(@files); $f++) { # test to see if it's a dir if ($files[$f] ne "." and $files[$f] ne ".." and $files[$f] !~ /\/ +/) { unless(-e "$path2\\$files[$f]") { exec("copy $path1\\$files[$f] $path2\\") || die "\n\nUnabl +e to copy $files[$f]. Error: $!\n\n"; }
|
|---|