Subject: | Regexp::Grammars does not work in Moose::Role |
Error msg: Global symbol "%keywords" requires explicit package name at (eval 172) line 32.
#!/usr/bin/env perl
use 5.018;
use warnings;
package ReRole;
use Moose::Role;
use Regexp::Grammars;
use Data::Dumper;
sub doit {
my %keywords = (foo => 1, bar => 1);
my $parser = qr/
^<keyword>$
<rule: keyword>
<%keywords>
/xms;
if ( "foo" =~ $parser ) {
warn Dumper(\%/);
}
}
package Re1;
use Moose;
with 'ReRole';
doit();
if you run the Regexp::Grammars code standalone it does not complain about the %keywords hash.