Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: how to permanently monitor a directory

by LanceDeeply (Chaplain)
on Aug 14, 2003 at 13:50 UTC ( #283872=note: print w/ replies, xml ) Need Help??


in reply to Re: how to permanently monitor a directory
in thread how to permanently monitor a directory

This:

my $items_in_dir = @Dircontent; if ($items_in_dir > 2) ..
won't work if some smart alec decides to create a subdir in your drop area. try using -f

TISMTOWTDI:

use strict; use warnings; sub scandir { my $dir = shift; my $fileProcessor = shift; opendir (DIR, $dir) or die "Cannot open $dir: $!\n"; for (readdir DIR) { if ( -f ) { &$fileProcessor($_); } } close DIR; } sub do_something { my $filename = shift; print "got file: $filename\n"; } sub do_something_else { my $filename = shift; print "got another file: $filename\n"; } scandir('.',\&do_something); scandir('.',\&do_something_else);


Comment on Re: Re: how to permanently monitor a directory
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://283872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (17)
As of 2014-10-21 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (103 votes), past polls