in reply to use utf8 pragma with moo

Within your Moo based module, try this:

package Foo; use Moo; use Data::Dumper; warn Dumper [sort keys %INC]; 1;

On my system with Perl 5.32 I get the following output:

$VAR1 = [ 'Carp.pm', 'Config.pm', 'Data/Dumper.pm', 'Exporter.pm', 'Foo.pm', 'List/Util.pm', 'Moo.pm', 'Moo/Object.pm', 'Moo/_Utils.pm', 'Moo/sification.pm', 'Scalar/Util.pm', 'Sub/Util.pm', 'XSLoader.pm', 'bytes.pm', 'constant.pm', 'mro.pm', 'overloading.pm', 'strict.pm', 'warnings.pm', 'warnings/register.pm' ];

So you can see that the utf8 pragma isn't enabled by default by Moo.

Can you provide a self-contained code snippet that demonstrates the namespace::clean issue? Also within the namespace::clean documentation, it does mention that you can pass an -except => [qw(foo bar)]; list of subs not to clean. Doing so may improve your experience.


Dave

Replies are listed 'Best First'.
Re^2: use utf8 pragma with moo
by AlexP (Pilgrim) on Jan 15, 2022 at 08:46 UTC

    Thank you very much for "warn Dumper sort keys %INC" - this is brilliant.

    The problem with namespace:

    use utf8; use feature qw(signatures); no warnings qw(experimental::signatures); use Moo; use namespace::clean; sub BUILD($self) { $self->_set_count(1); }

    An error: "The signatures feature is experimental ..."

    Should I place no warnings after namespace::clean or there are other solutions? Maybe with namespace::clean -except?

      The "problem" with Moo is that it re-enables all warnings that you previously disabled.

      So a solution is to disable warnings after the use Moo; line:

      use utf8; use feature qw(signatures); use Moo; no warnings qw(experimental::signatures);
        The "problem" with Moo is that it re-enables all warnings that you previously disabled

        That's odd ... why has the right to "Do What I Don't Mean" been bestowed upon Moo, when that sort of thing is generally frowned upon ?

        Thankfully, I don't use Moo and have no interest in it.
        However, I have just installed it to verify that it actually has this most unperlish capability ... and it does !!
        What's the spin that validates this ?

        Cheers,
        Rob
        Huh! Thanks for enlightenment!