.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "File::Monitor::Lite 3pm" .TH File::Monitor::Lite 3pm "2022-06-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" File::Monitor::Lite \- Monitor file changes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use File::Monitor::Lite; \& \& my $monitor = File::Monitor::Lite\->new ( \& in => \*(Aq.\*(Aq, \& name => \*(Aq*.html\*(Aq, \& ); \& \& 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; \& \`do blah..\` if $monitor\->anychange; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is another implementation 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 \f(CW$monitor\fR\->\fBcheck()\fR is executed. To use this module, just follow synopsis above. .PP Currently one cannot change file observing rules. To do so, create another monitor object with new rules. .PP .Vb 12 \& $m1=File::Monitor::Lite\->new( \& name => \*(Aq*.html\*(Aq, \& in => \*(Aq.\*(Aq, \& ); \& $m1\->check(); \& #blah... \& $m2=File::Monitor::Lite\->new( \& name => \*(Aq*.css\*(Aq, \& in => \*(Aq.\*(Aq, \& ); \& $m2\->check(); \& #blah... .Ve .SH "INTERFACE" .IX Header "INTERFACE" .ie n .IP """ new ( args ) """ 4 .el .IP "\f(CW new ( args ) \fR" 4 .IX Item " new ( args ) " Create a new \f(CW\*(C`File::Monitor::Lite\*(C'\fR object. .Sp .Vb 4 \& my $monitor = File::Monitor::Lite\->new( \& in => \*(Aq.\*(Aq, \& name => \*(Aq*.mp3\*(Aq, \& ); .Ve .Sp The syntax is inherited from File::Find::Rule. It will applied on File::Find::Rule as .Sp .Vb 4 \& File::Find::Rule \& \->file() \& \->name(\*(Aq*.mp3\*(Aq) \& \->in(\*(Aq.\*(Aq); .Ve .Sp As described in File::Find::Rule, name can be globs or regular expressions. .Sp .Vb 4 \& name => \*(Aq*.pm\*(Aq, # a simple glob \& name => qr/.+\e.pm$/, # regex \& name => [\*(Aq*.mp3\*(Aq, qr/.+\e.ogg$/], # array of rules \& name => @rules, .Ve .ie n .IP """ check() """ 4 .el .IP "\f(CW check() \fR" 4 .IX Item " check() " Check if any file recognized by File::Find::Rule has changed (created, modified, deleted.) The usage is simple: .Sp .Vb 1 \& $monitor\->check(); .Ve .ie n .IP """ created """ 4 .el .IP "\f(CW created \fR" 4 .IX Item " created " Returns an array of file names which has been created since last check. .ie n .IP """ modified """ 4 .el .IP "\f(CW modified \fR" 4 .IX Item " modified " Returns an array of file names which has been modified since last check. .ie n .IP """ deleted """ 4 .el .IP "\f(CW deleted \fR" 4 .IX Item " deleted " Returns an array of file names which has been deleted since last check. .ie n .IP """ observed """ 4 .el .IP "\f(CW observed \fR" 4 .IX Item " observed " Returns an array of file names which monitor is observing at. .SH "SEE ALSO" .IX Header "SEE ALSO" File::Find::Rule, File::Monitor .SH "AUTHOR" .IX Header "AUTHOR" dryman, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2011 by dryman .PP 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.