http://qs1969.pair.com?node_id=283849

LupoX has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

what is one of the best ways in perl to monitor a directory for incoming files?

My first idea was:

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;} }

I am shure there must be a better idea somewhere out there...

Thank you in advance!!
Georg -> perlmonk.23142@viot.de