This page is some recommendations about Perl modules for beginner programmers.
You can usually install a Perl module by downloading it from a CPAN copy and then doing the following kind of thing:
tar xfz Example-Module-0.1.tar.gz cd Example-Module perl Makefile.PL make make test make installYou can skip the "test" stage if the tests fail.
You can automatically install module dependencies using
cpan program which comes with Perl:
cpan Image::PNGIf the module doesn't install due to failing tests, you can use the
-foption to install it anyway:
cpan -f XML::ParserDespite what people will tell you, sometimes it really is necessary to do this.
cpan program is fairly reliable, but it produces a
lot of verbose output and nagging messages, so someone produced a
simpler thing called
cpanm installed via
App::cpanminus which is simpler to use. There is also something
called cpanplus in the standard Perl distribution, but this doesn't
work very well, and is best avoided.
File::Temp is a sensible way to do this.
File::Copy is part of Perl itself and is the best way to do this.
If you need to write tests to ensure that your Perl module functions correctly, the first place to look is Test::More. You can probably ignore the advice in the module's documentation to start with Test::Simple. Also, ignore the Test module, which is superceded by Test::More.
If you need to create something like an HTML page from Perl data, the first thing to look at is Template. Whatever you do, don't use the HTML generation in the CGI module.
The most standard helper is ExtUtils::MakeMaker.
The Module::Build module is hyped by a lot of Perl people, but for a beginner, it's extremely hard to use, since the module documentation is inadequate. You'll need to scrabble around looking for examples in other people's code if you use this, so avoid it.
If you want to connect to an SQL (standard query language, sometimes pronounced "sequel") database, the first thing to look at is DBI. Depending on what database you are using, you will also need to install a database driver. For example, for the MySQL database, you need to install DBD::mysql. For the SQLite database, you need to install DBD::SQLite.
There are also a lot of other things called "database" modules which aren't SQL style databases, but are just ways of storing hash tables onto a disk. These tend to show up in older Perl documentation.
The Carp module is the best way to make error messages for a module which relate to the point of calling of the module, so you can find out what call caused problems, rather than giving a message from deep inside the module itself.
There are some cases where the most sensible thing to do is to parse HTML using regular expressions.
If you need to find out where the executing file is, use
FindBin. The variable
$FindBin::Bin tells you
where the executable is.
You can find the location of a loaded library by looking at