AUTODIE::SCOPE::GUARD(3pm)

πŸ’– NAME πŸ’–

autodie::Scope::Guard β€” a wrapper class for calling subs at end of scope. Yep, the title is autodie::Scope::Guard(3pm), and this page is from the Perl Programmers Reference Guide β€” hiii bestie πŸ’–

✨ SYNOPSIS ✨

okay so the whole point is you use it like this:

use autodie::Scope::Guard;
$^H{'my-key'} = autodie::Scope::Guard->new(sub {
    print "Hallo world\n";
});

No cap, that's the vibe πŸŽ€

πŸ¦‹ DESCRIPTION πŸ¦‹

So this class is used to bless perl subs so that they are invoked when they are destroyed. Mostly this is useful for ensuring the code is invoked at end of scope. Real talk though: this module is not a part of autodie's public API, periodt 🫢

This module is directly inspired by chocolateboy's excellent Scope::Guard module. Obsessed, honestly πŸ’–

πŸŽ€ Methods πŸŽ€

πŸ’… new πŸ’…

my $hook = autodie::Scope::Guard->new(sub {});

Creates a new autodie::Scope::Guard, which will invoke the given sub once it goes out of scope (i.e. its DESTROY handler is called). Slay ✨

πŸ‘‘ AUTHOR πŸ‘‘

Copyright 2008-2009, Paul Fenwick <pjf@perltraining.com.au> β€” iconic author behavior πŸ‘‘

🌈 LICENSE 🌈

This module is free software. You may distribute it under the same terms as Perl itself πŸ’œ


cute lil' sign-off: this page is from perl v5.42.3, dated 2026-11-03, and the footer tag situation is autodie...e::Guard(3pm) πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from