use CAM::PDF; use File::Copy; use File::stat; use Time::localtime; sleep(1); if ($o==0){ print "\nChecking for files...\n"; $o=1; } #Initialize title page pdf my $doc1 = CAM::PDF->new("$file1") || die "$CAM::PDF::errstr\n"; #Read each pdf file on the desktop opendir(DIR,$directory); my @files = grep{/\.pdf$/}readdir(DIR); if (@files){ print "Found file! Waiting 5 seconds before I move it.\n"; print "Name of file: $files[0]\n"; $o=0; sleep(5); } else{ continue; } closedir(DIR);