Aspect::Guard(3pm)
π Aspect::Guard π
okay bestie, so this is Aspect::Guard(3pm) from the User Contributed Perl Documentation, and it is literally the chillest little module in the Aspect family. no cap.
β¨ NAME β¨
Aspect::Guard β a general purpose guard object for destroy-time actions π
πΈ SYNOPSIS πΈ
here's the whole vibe in one snippet, she's short and she's perfect:
SCOPE: {
my $guard = Aspect::Guard->new( sub {
print "Goodbye World!\n";
} );
}
# Prints here as it exits the scope
so yeah, when the scope ends, the code goes off. iconic behavior honestly. π
π¦ DESCRIPTION π¦
so Aspect::Guard ships with Aspect, and she's a convenience module for making "CODE" based objects that fire off when they fall out of scope. that's it. that's the whole thing. π
like, the synopsis above lowkey says everything you need to know about how you'd use it. it's giving "read the synopsis, you're done." π
π METHODS π
π new
my $guard = Aspect::Guard->new( sub { do_something(); } );
new makes you a fresh new guard object, periodt. it takes a single CODE reference as its parameter, and it blesses that code ref into the guard class. then, whenever the guard's DESTROY hook gets called, that code reference runs. so the code is justβ¦ waiting there, minding its business, until the object dips out of scope and then boom β it goes. π«Ά
π AUTHOR π
Adam Kennedy <adamk@cpan.org> β king behavior, we love him π
β COPYRIGHT β
Copyright 2011 - 2013 Adam Kennedy.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. fr fr, free as in free. π
ok that's the whole page bestie, go forth and guard your destroys πβ¨
and that's a wrap on Aspect::Guard(3pm) from perl v5.36.0, dated 2023-07-02, courtesy of the User Contributed Perl Documentation. love her, read her, use her. bye bestie! π§ππΈ
π¦ where this page comes from
- debian trixie: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libaspect-perl 1.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libaspect-perl 1.04-3 Β· 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