Maybe you can help me a little further: I have the following code that just listens for files in the in directory. When it finds a file in the "in" directory it forks and then copies the file to the "out" directory where a system call to FTP the file takes place.
My problem is that it forks just fine and it starts to FTP the files using the FTP_Client.exe program, however I get all these error messages ("Free to wrong pool ... C:/Perl/lib/IO/Dir.pm") before the program crashes.
Can anyone see what I am doing wrong? I am new with PERL.
THanks,
Andrew
My PERL code:
use IO;
use File::Copy;
use Fcntl ':mode';
use warnings;
use Net::ftp;
use Net::Ping;
use Time::localtime;
use POSIX ":sys_wait_h";
system ("color 1f");
my $indir = ".\\in";
my $outdir = ".\\out";
my $expr = "*.*";
my $RemFile = "*.*";
my $d;
if ( ! -e $indir ){
print "$indir does not exist, attempting to create\n";
mkdir ($indir, 0777 ) or die "Can not create $indir: $!";
}
if ( ! -e $outdir ) {
print "$outdir does not exist, attempting to create\n";
mkdir ($outdir, 0777 ) or die "Can not create $outdir: $!";
}
while(1){
$d = new IO::Dir "$indir";
tie %dir, IO::Dir, "$indir";
foreach (keys %dir) {
#if the expr is found in the InDir it will be FTP'd
if( ! S_ISDIR($dir{$_}->mode) && /^$expr/ ) {
if($pid = fork){
waitpid(-1, &WNOHANG);
}
else{
$RemFile = $_;
#move the file to the out directory
move( "$indir/$_", "$_");
#chdir ($outdir);
print "Starting to FTP: $_\n";
system("FTP_Client.exe $_");
print "Finished: $_ \n\n";
move( "$_", "$outdir/$_");
exit(1);
}
}
#sleep(5);
}
}
|