The only way I could get my program to work is to wait 5 seconds after it detects a file. I tried really hard to just get it to move the oldest file with File::DirList
@list = File::DirList::list('$directory','ia',1,1,1);
and stat, but I could never get the number out of the variables.
$last_modified = (stat($filename))[9]
My program works for me for now but who knows the kind of pressure people are going to put on it. Any hints on these in case I really do need to upload the oldest file?
My new code:
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);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|