File::...::Event(3pm)

πŸ“¦
version 0.31 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– 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. πŸ™Œ


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