4

I am trying to run a Perl script that, near the beginning, has

use Env '$Foo1', '$Foo2';

I am getting the following message:

Can't locate Env.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ../path/to/Foo3 line 8

I have tried to find the Env.pm module (find . -name Env.pm -print) but nothing happens, it just returns to the command prompt.

I am using RHEL7 and perl v5.16.3.

3 Answers 3

8

Install the perl-Env package to obtain Env.pm.

yum install perl-Env

You can also use the whatprovides feature of yum to see what packages provide files,

yum whatprovides */Env.pm

perl-Env-1.04-2.el7.noarch : Perl module that imports environment variables as scalars or arrays Repo        : base Matched from: Filename    : /usr/share/perl5/vendor_perl/Env.pm
0
1

RPM packaging has an established standard for noting what package contains what Perl module. The format is: perl(<NAME>). So in your case, you can run the command yum install 'perl(Env)', and see that it resolves to the perl-Env package. Unfortunately, you can't just depend on the package name itself, as some packages provide multiple modules, and things move in and out of the main perl package occasionally. The format above is the easiest way to consistently install the right package.

-1

You can also install Env module from cpan central repo which is equivalent to installing rpm package

1
  • 1
    It is not recommended to install with cpan or pip or pear or anything like this into the system which has packages managed with yum or apt or whatever. The consequences include that following ordinary package manager update system will broke and you'll work hard just to fix it. Don't do this yourself and never recommend this to anybody. You'd better recommend a concrete package to install with yum. Jan 5, 2021 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.