perlquestion
LupoX
<p>
Hi Monks,<br><br>
what is one of the best ways in perl to monitor a directory for incoming files?<br><br>
My first idea was:<br>
<code>
while (true) {
opendir (DIR, "/my/dir") or die "Cannot open /my/dir: $!\n";
my @Dircontent = readdir DIR;
close DIR;
my $items_in_dir = @Dircontent;
if ($items_in_dir > 2) { # > 2 because of "." and ".."
do_something_now(); # takes file(s) and moves them
}
else {sleep 100;}
}
</code>
</p>
<p>
I am shure there must be a better idea somewhere out there...
</p>
<p>Thank you in advance!!<br>Georg -> perlmonk.23142@viot.de</p>