Subject: | "no warnings" not recognized in DEMOLISH |
(Moo 2.003004, Perl v5.22.1)
Howdy!
I would like to suppress a warning during object destruction, but
DEMOLISH seems to ignore a "no warnings" directive. I've attached
code illustrating the behavior. In short,
use strict;
use warnings;
{
package MyWarning;
use warnings::register;
}
{
package Foo;
sub new { bless {}, shift() }
sub DESTROY {
warnings::warnif( 'MyWarning', 'warning enabled in ' . __PACKAGE__ );
}
}
suppresses the warnings, but the equivalent Moo class
{
package MooFoo;
use Moo;
sub DEMOLISH {
warnings::warnif( 'MyWarning', 'warning enabled in ' . __PACKAGE__ );
}
}
does not. The output of the attached code is:
% perl dbi.pl
expect warnings
warning enabled in MooFoo at (eval 9) line 21.
warning enabled in Foo at dbi.pl line 42.
expect no warnings
warning enabled in MooFoo at (eval 9) line 21.
Thanks as always for your efforts!
Diab
Subject: | dbi.pl |
#!perl
use strict;
use warnings;
{
package MyWarning;
use warnings::register;
}
{
package Foo;
use warnings;
sub new { bless {}, shift() }
sub DESTROY {
warnings::warnif( 'MyWarning', 'warning enabled in ' . __PACKAGE__ );
}
}
{
package MooFoo;
use Moo;
use warnings;
sub DEMOLISH {
warnings::warnif( 'MyWarning', 'warning enabled in ' . __PACKAGE__ );
}
}
print STDERR "\nexpect warnings\n";
{
MooFoo->new;
Foo->new;
}
print STDERR "\nexpect no warnings\n";
{
no warnings 'MyWarning';
MooFoo->new;
Foo->new;
}