16

When I'm trying to run a perl script (on my centos 6 machine) I get this message:

Can't locate JSON.pm in @INC (@INC contains: 
/usr/local/lib/perl5/5.10.1/x86_64-linux-thread-multi 
/usr/local/lib/perl5/5.10.1 
/usr/local/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi 
/usr/local/lib/perl5/site_perl/5.10.1 .)...

After googling a bit, I found out that I need to install that module; But, when I'm typing:

sudo yum install perl-JSON

I get this message:

    ...
Setting up Install Process
Package perl-JSON-2.17-1.el5.noarch already installed and latest version
Nothing to do

What can I do in order to run that script?

My perl version is v5.10.1

Thanks,

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Noam
  • 3,049
  • 10
  • 34
  • 52
  • Interesting, I was missing this module and was looking for a way to install it via yum instead of CPAN and your question answered it (yum install perl-JSON). This sorted it out on my CentOS 7. If CPAN works for you, maybe you could check which path is using. – Nagev Nov 23 '17 at 17:11

3 Answers3

26

Try to install it via:

1) CPAN (cpan install)

$ sudo cpan JSON

2) CPAN minus (cpanm)

Install cpan minus

$ wget http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.5017.tar.gz
$ tar -zxvf App-cpanminus-1.5017.tar.gz
$ cd App-cpanminus-1.5017
$ perl make.pl
$ make 
$ make test
$ sudo make install

Then install it via cpanm

$ sudo cpanm JSON

I prefer work with CPAN modules via cpanm, because it's modern and easy way!

Suic
  • 2,441
  • 1
  • 17
  • 30
Pavel Vlasov
  • 3,455
  • 21
  • 21
5

Maybe this will help others. In my case, running in Centos 7:

yum install cpan

then

yum install cpanminus 
inMILD
  • 168
  • 2
  • 12
2

for cpan (not cpan minus): yum install cpan cpan JSON

TamerDev
  • 79
  • 3
  • the first line "yum install cpan" is simpler since it gets it from the repo instead of compiling from source code (as in wget/tar/make). The second line "cpan JSON" is the same as in the accepted answer. – TamerDev Dec 04 '14 at 16:36
  • Thw wget/tar/make is for cpanminus, not plain cpan. His `sudo cpan JSON` is assuming you've already got `cpan` installed, true. – Rup Dec 04 '14 at 17:37
  • ok, I edited my answer to highlight that it is not for the cpan minus. – TamerDev Dec 04 '14 at 18:41