File::...::Event(3pm)
π File::ChangeNotify::Event β the manual, but make it cute β¨
okay so bestie, you found yourself in the File::...::Event(3pm) page (that's the File::ChangeNotify::Event manual, from the User Contributed Perl Documentation collection) and honestly? you're gonna be fine. it's giving "small class, big feelings". let's go π«Ά
β¨ NAME β¨
File::ChangeNotify::Event β the class that tells you what the heck just changed in your filesystem. it's the lil guy that carries the tea about a single file or directory change π
πΈ VERSION πΈ
version 0.31 β that's the one we're vibing with rn.
π¦ SYNOPSIS π¦
here's the whole plot in one code block, no cap:
my $watcher = File::ChangeNotify->instantiate_watcher(
directories => [ '/my/path', '/my/other' ],
filter => qr/\.(?:pm|conf|yml)$/,
exclude => [ 't', 'root', qr(/(?!\.)[^/]+$) ],
);
for my $event ( $watcher->new_events ) {
print $event->path, ' - ', $event->type, "\n";
}
see how it's just looping over events and printing the path and type? that's the whole vibe. obsessed π
π DESCRIPTION π
okay so this class is literally just a little info-delivery service: it hands you the deets about a change to one specific file or directory. one event, one change, one moment of drama. periodt. π
π METHODS π
π File::ChangeNotify::Event->new(...)
this makes you a brand new event, bestie. it accepts these args:
path => $pathβ the full path to the file or directory that changed. the whole thing, not a fragment. π₯type => $typeβ what kind of change happened. it must be one of"create","modify","delete", or"unknown". those four, nothing else, don't try it π
πΈ $event->path
hands you back the path of the changed file or directory. short, sweet, iconic.
β¨ $event->type
hands you back the type of the event. yep. that's it. we love a straightforward queen.
π¦ $event->has_attributes
this returns true for modify events that include info about a path's attribute changes. so like, if it's a modify event and it's got attribute gossip, this is true. otherwise? not true. π
π $event->attributes
if the event carries info about changes to a path's attributes, this gives you a two-element arrayref. each element is itself a hashref, and each of those will contain at least one of these keys:
permissionsβ the permissions mask for the path. πuidβ the user id that owns the path.gidβ the group id that owns the path.
heads up bestie: only keys which changed will be included. so don't go looking for all three every time, you'll get the changed ones and that's it. π
π§ $event->has_content
this returns true for modify events that include information about a file's content. yes, the actual contents. the plot. π
π $event->content
this returns a two-element arrayref where element one is the old content and element two is the new content. it's giving before-and-after. πΈ
β οΈ important, fr fr: this content is stored as bytes, not UTF-8. you will need to explicitly call "Encode::decode" on the content to make it UTF-8. and the reason it's like this? because there's no reason you couldn't use this feature with files containing any sort of binary data. so it stays bytes, on purpose, and that's a slay actually. π₯
π«Ά SUPPORT π«Ά
bugs may be submitted at <http://rt.cpan.org/Public/Dist/Display.html?Name=File-ChangeNotify> or via email to bug-file-changenotify@rt.cpan.org <mailto:bug-file-changenotify@rt.cpan.org>.
also, they're usually active on IRC as 'autarch' on "irc://irc.perl.org". so like, you can just... find them. in the wild. π
β SOURCE β
the source code repository for File-ChangeNotify can be found at <https://github.com/houseabsolute/File-ChangeNotify>. go look, it's right there, no gatekeeping π
π AUTHOR π
Dave Rolsky <autarch@urth.org> β the author. the main character. the one who wrote this whole thing. π
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2009 - 2019 by Dave Rolsky.
this is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
the full text of the license can be found in the LICENSE file included with this distribution. read it, bestie, it's good for you π
and that's the whole page!! this was perl v5.36.0, dated 2022-12-04, from the File::...::Event(3pm) manual π go forth and watch some files change, you absolute icon β¨π¦πΈ
π¦ where this page comes from
- debian bookworm: libfile-changenotify-perl 0.31-2 Β· Artistic-2.0
- debian trixie: libfile-changenotify-perl 0.31-2 Β· Artistic-2.0
- ubuntu noble: libfile-changenotify-perl 0.31-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms