Can anyone provide a real example of using File::Monitor?

I've been pounding away at perldoc File::Monitor, which seems to be
pretty thoroughly documented.... but as often seems to happen to me
its just not soaking in... how the scanning and reporting is supposed
to happen.  Somehow in the course of reading through the documentation
I just start to see red and don't get what is supposed to happen.

What I really want to do is monitor a directory recursively but here
just trying to use it any basic way to start to `get' how to use it.

Taking one of the examples offered at:
http://search.cpan.org/~andya/File-Monitor-0.10/lib/File/Monitor/Object.pm

With a few minor (but probably wrong) changes I get nothing printed
when the file is altered during the sleep.  The program just runs 10
seconds and closes. 

The example seems to be saying in the comments to just run
$monitor->scan; `later' and changes will be available.

   #!/usr/bin/perl

    use strict;
    use warnings;

    use File::Monitor;
    use File::Monitor::Object;

    my $monitor = File::Monitor->new();

    my @files = ( "./oldwork/test");         
    for my $file ( @files ) {
        $monitor->watch( $file );
    }

    # First scan just finds out about the monitored files. No changes
    # will be reported.
    $monitor->scan;
    sleep 10;
 
    # Later perform a scan and gather any changes
    for my $change ( $monitor->scan ) {
        # $change is a File::Monitor::Delta

## Also tried `print "$File::Monitor::Delta\n" -hp;

        print "change<$_>\n";
    }


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to