sub childsup{
print `dir /b $source\\*.txt > $source\\dir_list.lst`; #$source is declared just before the sub is called
print `copy $source\\dir_list.lst $script\\dir_list.lst`; #this copy works just fine.
open (DIR, "$source\\dir_list.lst")
||die "Can't Open list file";
@list=
;
close (DIR);
$cnt = 0;
Problems start here
foreach $tmp(@list) #This is the section which is meant copy/move several files to other Directories. This is the first and only time I use an Array in the script ‘ @list‘ all other moves or copies are done for one file and that file has a static name. The point of the move/copy is to archive and encrypt with PGP to send to a site via FTP.
{
use File::Copy;
$csfile = "\\$tmp";
$csarch = "\\\\hal\\public\\public\\boa\\archive";
#print "copy $source\\$tmp $dest\\$tmp"; #This prints what the next line should do, and the output is correct.
#print `copy $source\\$tmp $dest\\$tmp`; #This line will copy the file to the script directory instead of where it should go.
#print `move \\\\hal\\Public\\Public\\BOA\\$tmp \\\\hal\\Public\\Public\\BOA\\archive\\$tmp`;
#This line will move the file to the script directory instead of where it should go.
#copy("\\\\hal\\Public\\Public\\BOA\\$tmp", "\\\\hal\\Public\\Public\\BOA\\archive\\$tmp") || warn "File not moved $!";
# Here I use the perl File::Copy function as called above. But the script will output File not moved No such file or directory at Y:\SunTrust\scripts\Bank_master4.pl line 278. Although the files are there.
move("$source\\$tmp", "$dest\\$tmp") || warn "$tmp could not be moved $!"; # Here I use the perl File::Copy function as called above. But the script will output payroll_positive_pay.txt could not be moved Permission denied at Y:\SunTrust\scripts\Bank_master4.pl line 279.
$cnt = $cnt +1;
}
if ($cnt < 1) {
system("cls");
system("color cf");
print "\n";
print "\n";
print "There are no file is available.\n";
print "\n";
print "Please verify manually.\n";
print "\n";
$avil = 1;
print `pause`;
}
}