Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: File::Monitor problem with batch files

by xbmy (Friar)
on Nov 18, 2010 at 22:46 UTC ( #872368=note: print w/ replies, xml ) Need Help??


in reply to File::Monitor problem with batch files

Finally, I tried the following code, it works perfectly for monitoring all the files in a directory! Thanks you all!

use File::Monitor; use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove); my $monitor = File::Monitor->new(); $files= 'c:\\PAPERS'; opendir(AA,$files) || return; my @list = readdir(AA); closedir (AA); foreach $file (@list) { $monitor->watch( $file ); } $monitor->callback( mtime => sub { my ($file, $event, $change) = @_; print "$file has been modified \n\n"; fcopy ("$file","p:\\phdpaper"); } ); while (1) { $monitor->scan; sleep 10; # After the first scan we get a list of File::Monitor::Delta obje +cts # that describe any changes my @changes = $monitor->scan; for my $change (@changes) { # Call methods on File::Monitor::Delta to discover what change +d if ($change->is_mtime) { my $name = $file_name; } } }


Comment on Re: File::Monitor problem with batch files
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-11-28 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (199 votes), past polls