File::...r::Lite(3pm)
π File::Monitor::Lite β monitor file changes π
okay bestie, listen. this is File::Monitor::Lite, and it watches your files for you like the loyal little main character it is. it lives in the Perl user-contributed docs section. let's go β¨
πΈ 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;
`do blah..` if $monitor->anychange;
}
likeβ¦ that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
so this is another implementation of File::Monitor. here's the tea: File::Monitor cannot detect file creation unless you declare the file name first π. so instead, this module uses File::Find::Rule to rescan files every single time $monitor->check() is executed. fr fr. to use it, just follow the synopsis above and you're slaying π
currently, you cannot change file observing rules on an existing monitor. to switch things up, you just make another monitor object with new rules. periodt:
$m1=File::Monitor::Lite->new(
name => '*.html',
in => '.',
);
$m1->check();
#blah...
$m2=File::Monitor::Lite->new(
name => '*.css',
in => '.',
);
$m2->check();
#blah...
see? new rules, new object, no drama π
β¨ INTERFACE β¨
π " new ( args ) "
creates a brand new File::Monitor::Lite object. iconic behaviour honestly.
my $monitor = File::Monitor::Lite->new(
in => '.',
name => '*.mp3',
);
the syntax is inherited from File::Find::Rule π§ and it gets applied onto File::Find::Rule like this:
File::Find::Rule
->file()
->name('*.mp3')
->in('.');
and as described in File::Find::Rule, name can be globs or regular expressions β literally whatever your heart desires:
name => '*.pm', # a simple glob
name => qr/.+\.pm$/, # regex
name => ['*.mp3', qr/.+\.ogg$/], # array of rules
name => @rules,
π " check() "
checks if any file recognized by File::Find::Rule has changed β created, modified, or deleted. the usage is giving very simple:
$monitor->check();
π " created "
returns an array of file names that have been created since the last check π±
π " modified "
returns an array of file names that have been modified since the last check βοΈ
π " deleted "
returns an array of file names that have been deleted since the last check π
π " observed "
returns an array of file names that the monitor is observing at π
ngl, the synopsis also hits us with$monitor->anychangeinside thatifβ it's right there in the example, bestie π«Ά
π SEE ALSO π
File::Find::RuleFile::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. slay β¨
okay that's the whole page, no cap π«Ά this was File::...r::Lite(3pm), from perl v5.34.0, dated 2022-06-13 β mwah, go monitor something cute π
πΈ
π¦ where this page comes from
- debian bookworm: libfile-monitor-lite-perl 0.652003-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libfile-monitor-lite-perl 0.652003-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libfile-monitor-lite-perl 0.652003-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfile-monitor-lite-perl 0.652003-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfile-monitor-lite-perl 0.652003-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms