views:

301

answers:

2

I'm new to Perl. How do you install the Net::SFTP module? I'm running Ubuntu Linux. I believe there's a simple way to do it from the command line, like by calling $ cpan install or something.

+2  A: 

Generally the command-line way to install perl modules is:

perl -MCPAN -e "install Net::SFTP"

There are instances where it is better to install perl modules from the packages or ports or other similar systems which come with a particular distribution. Because some Perl modules make use of compiled C code, and C code compilation and dependencies can vary. For instance, I use OpenBSD for most of my servers and I generally use the version I find in the packages for a given version of the OS if there is one, and if there isn't one in the packages I assume it is safe to install it from CPAN and that generally works for me.

Devin Ceartas
+1  A: 

An option that's quite common is to use the packages from your distribution, with apt-get or aptitude (or any graphical tool you like).

If that package is not provided by your distribution, you can :

  • First, install the cpan command, if not already installed, with something like : apt-get install cpan
  • And, then, use the cpan command to install your package : cpan -i Net:SFTP
    (Note it'll ask lots of questions -- like should it also install required packages)
  • If needed, you can access the documentation of the cpan command : cpan -h or perldoc -F /usr/bin/cpan (might require the perl-doc package)
Pascal MARTIN