Subject: | Keyword::Declare does not seem to work with __DATA__ in a module |
Date: | Thu, 11 Jul 2019 08:37:39 +0000 |
To: | "bug-keyword-declare [...] rt.cpan.org" <bug-keyword-declare [...] rt.cpan.org> |
From: | Jeroen Paasschens <Jeroen.Paasschens [...] synopsys.com> |
Hi Damian,
Thanks for the fast response on the issue [rt.cpan.org #130031] for Test::Expr.
The disadvantage of a small test-case is that sometimes you miss an important point. So yes, the initial test-case I sent now works. But in my application I still had issues. Therefore a bug report now against Keyword::Declare (where I guess it belongs). The main difference is now that there is a DATA in a module, not in the main perl file:
I reduced this now to the following.
try.pl contains:
use lib '.';
use TestKD;
TestKD.pm contains:
package TestKD;
use strict;
use warnings;
use true; #otherwise it will give an error on not returning a true value
use Keyword::Declare;
my $data_content = do { local $/ = undef; <DATA>};
print $data_content;
1;
__DATA__
content
The error on running try.pl is now:
readline() on unopened filehandle DATA at TestKD.pm line 7.
Use of uninitialized value $data_content in print at TestKD.pm line 8.
Name "TestKD::DATA" used only once: possible typo at TestKD.pm line 7.
Note that I am not even using Keyword::Declare, just loading it.
For completeness, this is perl 5.28.1; the versions of packages loaded:
'B::Hooks::EndOfScope' => '0.24',
'B::Hooks::EndOfScope::XS' => '0.24',
'B::Hooks::OP::Annotation' => '0.44',
'B::Hooks::OP::Check' => '0.22',
'Carp' => '1.50',
'Config' => '5.028001',
'Cwd' => '3.74',
'Devel::StackTrace' => '2.03',
'Devel::StackTrace::Frame' => '2.03',
'DynaLoader' => '1.45',
'Exporter' => '5.73',
'File::Spec' => '3.74',
'File::Spec::Unix' => '3.74',
'TestKD' => 'unknown',
'Keyword::Declare' => '0.001013',
'Keyword::Simple' => '0.03',
'List::Util' => '1.5',
'Module::Implementation' => '0.09',
'Module::Runtime' => '0.016',
'PPR' => '0.000022',
'PerlIO' => '1.10',
'PerlIO::scalar' => '0.29',
'Scalar::Util' => '1.5',
'Sub::Exporter::Progressive' => '0.001013',
'Sub::Util' => '1.5',
'Tie::Hash::NamedCapture' => '0.10',
'Try::Tiny' => '0.30',
'Variable::Magic' => '0.62',
'XSLoader' => '0.30',
'base' => '2.27',
'constant' => '1.33',
'if' => '0.0608',
'lib' => '0.64',
'overload' => '1.30',
'overloading' => '0.02',
'parent' => '0.236',
're' => '0.36',
'strict' => '1.11',
'true' => 'v1.0.1',
'utf8' => '1.21',
'vars' => '1.04',
'version' => '0.9923',
'version::regex' => '0.9923',
'warnings' => '1.42',
'warnings::register' => '1.04',
Best regards
Show quoted text
________________________________________________________________
Jeroen Paasschens High Tech Campus 41-1.42, 5656 AE Eindhoven, The Netherlands +31 40 2304725