Subject: | requires() function reports funny things if module prints to STDOUT |
If you use requires() to get dependencies for a module which prints things to stdout, for
example in an END block, then you'll get confusing results.
And if the module is one of the other modules for getting dependencies, then you might get
modules listed twice, or some slightly interesting output. Eg
@deps = requires('Devel::Loaded');
foreach my $module (@deps) {
print " $module\n";
}
Which results in:
::usr::local::lib::perl5::5.16.2::darwin-2level::File::Spec
::usr::local::lib::perl5::5.16.2::darwin-2level::File::Spec::Unix
::usr::local::lib::perl5::5.16.2::strict
::usr::local::lib::perl5::5.16.2::vars
::usr::local::lib::perl5::5.16.2::warnings::register
::usr::local::lib::perl5::site_perl::5.16.2::Devel::Loaded
Devel::Loaded.pm::usr::local::lib::perl5::5.16.2::warnings
File::Spec
File::Spec::Unix
strict
vars
warnings
warnings::register
My first thought for a solution is very hacky: in the sub-process, once you've printed the
modules, you could
close(STDOUT);
I know, I know, but it does work ;-)
And possibly reopen it to /dev/null (um, portably of course), to stop anything barfing.