Aspect::Guard(3pm)

πŸ“¦
version 1.04 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

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