NAME

File::Monitor::Lite - Perl extension for blah blah blah

SYNOPSIS

use File::Monitor::Lite;

my $monitor = File::Monitor::Lite->new (
    in => '.',
    name => '*.html',
);

while ($monitor->check() and sleep 1){
    my @deleted_files = $monitor->deleted;
    my @modified_files = $monitor->modified;
    my @created_files = $monitor->created;
    my @observing_files = $monitor->observed;
}

DESCRIPTION

This is another implementaion of File::Monitor. While File::Monitor cannot detect file creation (unless you declare file name first), I use File::Find::Rule to rescan files every time when $monitor->check() is executed. To use this module, just follow synopsis above.

Currently one cannot change file observing rules. To do so, create another monitor object with new rules.

$m1=File::Monitor::Lite->new(
    name => '*.html',
    in => '.',
);
$m1->check();
#blah...
$m2=File::Monitor::Lite->new(
    name => '*.css',
    in => '.',
);
$m2->check();
#blah...

INTERFACE

new ( args )

Create a new File::Monitor::Lite object.

my $monitor = File::Monitor::Lite->new(
    in => '.',
    name => '*.mp3',
);

The syntax is inherited from File::Find::Rule. It will applied on File::Find::Rule as

File::Find::Rule
    ->file()
    ->name('*.mp3')
    ->in('.');

As described in File::Find::Rule, name can be globs or regular expressions.

name => '*.pm',                     # a simple glob
name => qr/.+\.pm$/,                # regex
name => ['*.mp3', qr/.+\.ogg$/],    # array of rules
name => @rules,
check()

Check if any file recognized by File::Find::Rule has changed (created, modified, deleted.) The usage is simple:

$monitor->check();
created

Returns an array of file names which has been created since last check.

modified

Returns an array of file names which has been modified since last check.

deleted

Returns an array of file names which has been deleted since last check.

observed

Returns an array of file names which monitor is observing at.

SEE ALSO

File::Find::Rule, File::Monitor

AUTHOR

dryman, <idryman@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2011 by dryman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.