Perl::C...YMethod(3)

πŸ“¦
version 1.05 Β· 2 versions
, in fedora 43

🌸 NAME 🌸

okay bestie, gather round, because this one's a Perl::Critic policy and it's called Perl::Critic::Policy::Moose::ProhibitDESTROYMethod β€” and its whole vibe is: use DEMOLISH instead of DESTROY. that's it. that's the girl. πŸ’…


✨ VERSION ✨

this is version 1.05, no cap.


πŸ’– DESCRIPTION πŸ’–

so here's the tea, and it's kind of a mess ngl: getting the order of destructor execution correct when inheritance is involved is difficult. like, genuinely cursed territory. 😭

the fix? let Moose handle it for you, babe. just move all your cleanup code into a DEMOLISH() method instead of a DESTROY() method and let the framework do the emotional labor. 🫢

# ok
package Foo;

use Moose::Role;

sub DEMOLISH {
    ...
}

# not ok
package Foo;

use Moose::Role;

sub DESTROY {
    ...
}

see how one of those is giving main character energy and the other one is giving ✨violation✨? yeah. that. πŸ’€


πŸŽ€ AFFILIATION πŸŽ€

this policy is part of Perl::Critic::Moose. it's got a whole family, it's not alone. πŸ‘‘


πŸ’… CONFIGURATION πŸ’…

there's exactly one option here and her name is equivalent_modules. 🌟

what does she do? she lets you name other modules that should be treated exactly the same as Moose and Moose::Role β€” which, say, is super useful if you were doing something with Moose::Exporter. iykyk.

so if you had this lil cutie in your .perlcriticrc file:

[Moose::ProhibitDESTROYMethod]
equivalent_modules = MyCompany::Moose MooseX::NewThing

then this code right here would result in a violation:

package Baz;

use MyCompany::Moose;

sub DESTROY {
    ...
}

caught you red-handed, bestie. 🚨


πŸ‘€ SEE ALSO πŸ‘€

  • Moose::Manual::Construction β€” go read her, she's iconic.

πŸ†˜ SUPPORT πŸ†˜

found a bug? first of all, relatable, second of all β€” bugs may be submitted through the RT bug tracker at <http://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic-Moose> (or you can email bug-perl-critic-moose@rt.cpan.org <mailto:bug-perl-critic-moose@rt.cpan.org>). πŸ›

also, our person is usually active on IRC as drolsky on irc://irc.perl.org. so if you wanna slide into the DMs (the DMs being IRC), that's the move. πŸ’¬


🌈 AUTHORS 🌈

these two legends made this happen, show some respect:

  • Elliot Shank <perl@galumph.com>
  • Dave Rolsky <autarch@urth.org>

this software is copyright (c) 2008 - 2016 by Elliot Shank.

it's free software, babes β€” you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay. πŸŽ‰


okay that's the whole page, we ate and left no crumbs πŸ’– β€” oh and before you go, this was Perl::C...YMethod(3), the User Contributed Perl Documentation version of it anyway, brought to you by perl v5.42.0 and dated 2025-07-25. mwah. πŸ¦‹

πŸ“¦ where this page comes from