You can use Perl to interactively download and install a Perl module from the CPAN archives by using the -m and -e commands. Start the process by using a Perl like this:
After you press Enter, you will see some introductory information and be asked to choose an initial automatic or manual configuration, which is required before any download or install takes place. Type no and press Enter to have Perl automatically configure for the download and install process; or, if desired, simply press Enter to manually configure for downloading and installation. If you use manual configuration, you must answer a series of questions regarding paths, caching, terminal settings, program locations, and so on. Settings are saved in a directory named .cpan in current directory. When finished, you will see the CPAN prompt:
To have Perl examine your system and then download and install a large number of modules, use the install keyword, specify Bundle at the prompt, and then press Enter like this:
cpan> install Bundle::CPAN
To download a desired module (using the example in Listing 27.6), use the get keyword like so:
cpan> get Mail::Sendmail
The source for the module will be downloaded into the .cpan directory. You can then build and install the module using the install keyword, like this:
cpan> install Mail::Sendmail
The entire process of retrieving, building, and installing a module can also be accomplished at the command line by using Perl's -e option like this:
# perl -MCPAN -e "install Mail::Sendmail"
Note also that the @ sign did not need to be escaped within single quotation marks (''). Perl does not interpolate (evaluate variables) within single quotation marks, but does within double quotation marks and here strings (similar to << shell operations).
Was this article helpful?