open(FILE,"<",$file); binmode(FILE); if (flock(FILE,LOCK_EX|LOCK_NB)) { my $buf = ""; report("Info: Processing $file"); #make sure this is a pcl job file first #if not, move it and log it read(FILE,$buf,9); $printstring = $printstring.$buf; unless($buf =~ m/^\x1B\x25\x2D\x31\x32\x33\x34\x35\x58/) { close(FILE); my $errdir = "$dir\\ERR"; report ("Warning: $file is not a valid PCL file - moving to ERR folder"); unless(-d $errdir){mkdir($errdir);} move($file,$errdir); next; } while(read(FILE,$buf,4096)) { fixtraycalls(\$buf); $printstring= $printstring.$buf; } close FILE;#closing file flushes buffer and releases lock if($keepfile) { my $dest; sleep 1; eval{ $dest = $$appconfig{"destination"}."\\$filename"; Win32::CopyFile($file,$dest,1); }; if($!) { report("Error: Unable to move file to destination - ".$dest."\n $!"); #die; } }