in reply to CoreList stuff

I think you misunderstood what Module::CoreList is for: it tells you about the "core" modules, i.e. the ones that are included by default with any distribution of perl. It's often useful to know when a paticular core module entered the core, if you're trying to support older versions of perl.

A common way of finding out if you have a module is:

perl -MSome::Module -e'print $Some::Module::VERSION, "\n"'
If you get a version number, it's there, if not, you don't have it.

From within perl code, I'd be inclined to require it and trap the error to find out if the require failed. Something like this:

use Carp; my $module = "CGI"; eval "require $module"; if ($@) { carp "Problem with require of $module: $@"; } else { print "We have $module installed\n"; }

Replies are listed 'Best First'.
Re^2: CoreList stuff
by doom (Deacon) on Feb 01, 2009 at 22:30 UTC
    Funny, I've been having trouble getting the version number of the module in the above code. This works, but I have a feeling there's a better way:
    use Carp; my $module = "CGI"; eval "require $module"; if ($@) { carp "Problem with require of $module: $@"; } else { { no strict "refs"; my $version = ${ $module. "::VERSION" }; print "We have $module installed, version: $version\n"; } }
      warn UNIVERSAL::VERSION($module); warn $module->VERSION;