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

Hi, I have recently migrated to linux & I have to use perl. I want to transfer a .pm file to the lib folder in perl, so that I can execute a perl program that depends on it. In windows it is in perl/lib. But I dont know how to find that folder in Ubuntu. Is there a way to execute the perl program when I know the place of the .pm file? Thank you raghul

Replies are listed 'Best First'.
Re: finding pm files in linux
by Corion (Patriarch) on Feb 29, 2012 at 10:10 UTC

    Consider looking at perlrun and perlvar for @INC.

    Also, the Perl that came with your operating system belongs to your operating system. System utilities may depend on the system Perl working properly and having exact versions of certain modules installed. Do not manually install (or "copy") files into its directories. Use your operating system package manager to install Perl modules for the system Perl.

    Also see local::lib and/or App::perlbrew.

    For the general process of module installation, see Yes, even you can use CPAN and CPAN resp. CPANPLUS or App::cpanminus.

Re: finding pm files in linux
by moritz (Cardinal) on Feb 29, 2012 at 10:12 UTC

    You can find out about the location of a module with

    $ perldoc -l Data::Dumper /home/moritz/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/x86_64-linux/ +Data/Dumper.pm
    Is there a way to execute the perl program when I know the place of the .pm file?

    There are various ways to adjust the module search path. See perlrun for the complete list.

    But it sounds like you really want a proper module installation with the CPAN module/program.

Re: finding pm files in linux
by Eliya (Vicar) on Feb 29, 2012 at 10:11 UTC

    You can type perl -V  (capital V !) to find out Perl's default lib search paths (the @INC array).

    But your modules don't necessarily need to be installed in the default search paths.  You can alwas use one of the following to change where Perl looks for modules:

    • use lib ...
    • the PERL5LIB environment variable
    • the -I command line option
    • manipulating @INC directly, e.g. BEGIN { unshift @INC, "/path/to/libs" }
Re: finding pm files in linux
by pvaldes (Chaplain) on Feb 29, 2012 at 18:07 UTC

    I dont know how to find that folder in Ubuntu

    find / -name '*.pm' |less