use if eval { require mod; 1 }, qw' constant haveMod 1 ';
is ugly because constant is being used. I pointed out that it's simply not true. Not only does that code not work, but it can be written as
use constant haveMod => eval { require mod; };
I am sniffing to see what PMs were loaded before the "use" that loads my PM.
Asked and answered. Or if you want to check for multiple modules,
use constant {
map {
no strict 'refs';
( my $constant = $_ ) =~ s/:://g;
"have$constant" => ${"${_}::VERSION"}
} qw(
Foo::Mod
Bar::Mod
);
};
|