BEGIN failed–compilation aborted at Perl – Can’t locate cpan.pm in @inc


Error:

Can’t locate Scalar/Util.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 /home/xnavin) at /usr/share/perl5/Safe.pm line 5.
BEGIN failed–compilation aborted at /usr/share/perl5/Safe.pm line 5.
Compilation failed in require at /usr/share/perl5/CPAN.pm line 55.
BEGIN failed–compilation aborted at /usr/share/perl5/CPAN.pm line 55.
Compilation failed in require at /usr/share/perl5/App/Cpan.pm line 183.
BEGIN failed–compilation aborted at /usr/share/perl5/App/Cpan.pm line 183.
Compilation failed in require at /usr/bin/cpan line 8.
BEGIN failed–compilation aborted at /usr/bin/cpan line 8.

Reason of the error:

Some perl module is missing.

Solution:

Find out the missing perl rpm and installs it.

In this error Find and edit Util.pm
#locate Util.pm
edit  /usr/lib/perl5/Hash/Util.pm and find the error line 8

it shows
use Scalar::Util qw(reftype);

In my case perl-Scallar was not installed
install perl-Scallar*

#yum install perl-Scallar*

That’s all.