use v5.14; use Regexp::Grammars; my $sentence = "Show me the money"; my $grammar = qr{ ? <.Word> ? <.Word> me | us | them a | an | the | some \w+ }x; sub parse { my $s = shift; say "The sentence is: $s"; if ($s =~ $grammar) { use Data::Dumper; print Dumper \%/; } else { say "I did not understand you." } } parse ($sentence);