Open perlpunk opened 5 years ago
The cause of this is what's in http://perldoc.perl.org/perldata.html, about __END__
:
For compatibility with older scripts written before
__DATA__
was introduced,__END__
behaves like__DATA__
in the top level script (but not in files loaded withrequire
ordo
) and leaves the remaining contents of the file accessible viamain::DATA
.
Repro to demonstrate:
$ cat >>tf2.pl <<EOF; perl tf2.pl
package Other; require Scalar::Util; print Scalar::Util::openhandle( \*main::DATA ), "\n";
__END__
Yo
EOF
It prints a GLOB(blah)
with and without the package
declaration.
Context: this happens with:
$ echo "Test::YAML 0" | perl `perldoc -l CPAN::Reporter::PrereqCheck`
CPAN::Reporter::PrereqCheck
has an __END__
section. If called as a script (rather than loaded with -M
etc), it behaves in the above-mentioned way.
Since CPAN::Reporter::PrereqCheck
has a number of exceptions of modules to not load, it seems reasonable to simply add Test::YAML
to that list of exceptions.
See https://github.com/ingydotnet/test-yaml-pm/issues/3 and https://github.com/ingydotnet/yaml-pm/issues/210
I tried to fix this with https://github.com/ingydotnet/test-base-pm/pull/21 but the fix only works if the main::DATA section is empty.
Not sure how to solve this.