Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks.. I am a beginner in perl. I am trying to install perl modules from CPAN by downloading tar files (coz CPAN command methos causing me permission denied probles on my ubuntu machine even with the sudo command.) now I am successfully able to install the modules using tar files but issue is that they are installed not on the correct path, means it is not being considered by @INC array. so what I have to do, is to add those paths using BEGIN & unshift for each and every module.. something like below

BEGIN { unshift (@INC, "/home/eankuls/.cpan/build/Net-SSH-Perl-1.37-KSvjy6/bli +b/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Crypt-DH-0.07-B70AtC/blib/li +b"); unshift (@INC, "/home/eankuls/.cpan/build/Digest-SHA1-2.13-lHIaOb/blib +/lib"); }

so is there any way so that they can install at the correct path? please let me know if you need more info. as I am new in perl and might be missing some necessary info. thanx

Replies are listed 'Best First'.
Re: How to install (download) CPAN module on the correct path.
by tobyink (Canon) on May 01, 2014 at 08:06 UTC

    The /home/eankuls/.cpan/build/* paths are temporary directories used by CPAN while it's building modules, but before installing them. Don't use these paths in production code because CPAN could delete them without asking you. (They're temporary!)

    If you're having trouble with permissions installing CPAN modules, then consider using local::lib to establish a location in your own home directory for installing modules. As it will be within your home directory, there should be no permissions problems. local::lib also works very nicely together with cpanminus, which is an alternative to the normal CPAN command-line client.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

      I installed local::lib module and then tried to install Net::SFTP, but it is still showing the same error.

      an't locate Net/SFTP.pm in @INC (@INC contains: /etc/perl /usr/local/l +ib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share +/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_pe +rl .) at ankur_ftp.pl line 13.

      Am i skipping any step? I mean i Just installed local::lib module. I don't know how this @INC array will start considering those paths where my modules are installed. Could you please tell me in details.....thnx a lot..

        "I installed local::lib module and then tried to install Net::SFTP"

        How? As I've asked before, be specific. You say you tried to install Net::SFTP but don't show how you tried to do this, or what when wrong. Did you read the link to the local::lib documentation I gave you? It looks like you haven't updated your code to reflect that fact that you want to use local::lib. Again examples in the documentation.

Re: How to install (download) CPAN module on the correct path.
by marto (Cardinal) on May 01, 2014 at 08:40 UTC

    These paths are not what you think they are, tobyink explains your mistake well.

    The first time you run cpan it will explain may things and ask if you want to use local::lib (read the Rationale). With this method you can install modules without root permissions.

    A saner alternative is to install your own version of perl there's an automated method (perlbrew) or a manual method, both are fairly trivial, read this post for details.

    Update: fixed typo.

Re: How to install (download) CPAN module on the correct path.
by Anonymous Monk on May 01, 2014 at 08:02 UTC
Re: How to install (download) CPAN module on the correct path.
by Anonymous Monk on May 01, 2014 at 08:29 UTC

      lol..you forgot too...

        "lol", I don't have an account, enjoy your problems.