Subject: | Keyword::Declare fails with postfix dereferencing |
Date: | Sun, 3 Dec 2017 23:02:01 +0100 |
To: | bug-Keyword-Declare [...] rt.cpan.org |
From: | Curtis Poe <ovid [...] allaroundtheworld.fr> |
Hi Damian,
Keyword::Declare is a lovely module, but I've found an edge case that's
troublesome.
#!/usr/bin/env perl
use 5.024;
use Keyword::Declare;
keyword DEVELOPMENT( Block $block) {
if ( $ENV{PERL_KEYWORD_DEVELOPMENT} ) {
return $block;
}
return "# Code Omitted";
}
my $aref = [ 1, 2, 3 ];
DEVELOPMENT {
my @example = map { $_ => $_ } $aref->@*;
print join '-' => @example;
}
That code fails with:
$ PERL_KEYWORD_DEVELOPMENT=1 perl declare.pl
Invalid DEVELOPMENT at declare.pl line 14.
Expected:
DEVELOPMENT <block>
but found:
DEVELOPMENT {
Compilation failed at declare.pl line 14.
If I change the postfix dereferencing to @$aref, it works just fine.
Curtis "Ovid" Poe
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/