1nickt has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I have a Moo role in which I declare some constants with:
package MyRole; use Moo::Role; use constant INDEX_FOO => 42; ...
The constants are not available in the consuming class:
package MyClass; use Method::Signatures; use Moo; use namespace::clean; with 'MyRole'; my $aref = get_some_stuff(); my $thing = $aref->[ INDEX_FOO ]; ...
The error:
Bareword "INDEX_FOO" not allowed while "strict subs" in use at ...
Is this expected behaviour? And, can I export my constants from a role to its consumer somehow?
Thank you, kind monks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Exporting constants from a Moo role
by tobyink (Canon) on Aug 02, 2018 at 13:03 UTC | |
by 1nickt (Canon) on Aug 02, 2018 at 21:43 UTC | |
Re: Exporting constants from a Moo role
by Corion (Patriarch) on Aug 02, 2018 at 10:42 UTC | |
by 1nickt (Canon) on Aug 02, 2018 at 21:25 UTC | |
Re: Exporting constants from a Moo role
by anonymized user 468275 (Curate) on Aug 02, 2018 at 12:08 UTC | |
by tobyink (Canon) on Aug 02, 2018 at 16:00 UTC | |
by 1nickt (Canon) on Aug 02, 2018 at 21:40 UTC | |
by tobyink (Canon) on Aug 03, 2018 at 11:49 UTC | |
by 1nickt (Canon) on Aug 02, 2018 at 21:26 UTC |