How do I know what modules are distributed with Perl?
My first guess is that the core modules listed here are always included, though I cannot find this stated explicitl
sounds like you want local::lib. All the benifits of cpan without root (and leaves the system perl untouched).
The correct straight forward answers have already been given, but I think you've asked the wrong question. You're probably trying to develop using only core modules. Why? You're probably doing this because you don't want to deal with dependencies. Why? Because they can be a pain in the ass. But developing Perl without CPAN is missing half the power. You're crippling yourself. It's worth it.
Update: Now that I know more about what you're trying to do, I can answer the right question. First is "how do I install a module when I don't have root?" The simple answer is this:
perl Makefile.PL PREFIX=/some/path LIB=/some/path/lib
...and all the rest as normal...
for MakeMaker based modules (LIB is used to control the otherwise inexact nature of PREFIX. INSTALL_BASE is preferred, but it is not backwards compatible).
and this for Module::Build
perl Build.PL --install_base=/some/path
and then modules will wind up in /some/path/lib and you can set the PERL5LIB
environment variable or use lib qw(/some/path/lib)
in your code.
This means you can stick dependent modules straight into your software distribution and ship them. Works fine for pure-Perl modules. For stuff that requires a compiler, look at PAR as others have suggested to be able to ship compiled executables.
Alternatively, you can distribute your stuff as a CPAN module, complete with dependencies spelled out, and let a CPAN client resolve them. You can even use Module::AutoInstall to perform this process outside of a CPAN client.
So you see, you're not restricted to using just core modules when shipping a Perl app.
This question is a little less important now (I have root access on the eventual target machine so I'll just be installing the packages I need) but in case anyone is interested here's what I did:
First, run this code on each of the target systems:
foreach my $dir (@INC) {
print "Directory: $dir\n";
if (-d "$dir") {
my @modules = `find $dir/ -name "*.pm"`;
foreach my $m (@modules) {
my $label = $m;
$label =~ s|\n$||;
$label =~ s|//+|/|g;
$label =~ s|^$dir/||;
print "$label\n";
}
}
}
Note you need a *nix system with a find command. Dump the output into three files, sorted. Then use commands like this (from memory):
grep -F -x -f list-1.txt list2.txt > list-12.txt
grep -F -x -f list-12.txt list3.txt > list-123.txt
Now list-123.txt should have the list of shared modules, more or less.
For what it's worth, all three systems shared a few extra modules, notably the XML::Parser modules.
Module::CoreList has already been mentioned. It comes with a command-line interface to make things easy. It's great if you have it installed already, or have a program that needs to figure out what may not come with a particular version of Perl.
If you want to know what modules come with your particular version of perl, you can run perldoc perlmodlib
on the command line for a complete list. For older or newer versions of Perl, you can just go to Perl's page on the CPAN and select the version you want (eg, 5.6.2) from the drop-down, and then navigate to the perlmodlib
page in the documentation. (typing perlmodlib
into your browser's text search will help).
If you're thinking of not using a module because it's not core on an older version of Perl, then you may wish to consider using PAR, the Perl Archiver, to bundle your extra dependencies, or even Perl itself! Perl Training Australia also has a Perl Tip on using PAR which covers the basics on getting started with PAR.
All the very best,
Paul
If you install Module::CoreList, the command line program corelist
can tell you everything about modules and their versions in different versions of perl. The page you linked to gives an overview for the latest version of perl.
Do note that distributions often provide much more by default than this list, but this list can be assumed to be present everywhere (unless it is explicitly a OS dependent module such as Win32).
look in you main symbol table, it will show you all the 'standard' packages available...
print %main::;