Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

networking with perl

by varalaxmibbnl (Acolyte)
on Sep 06, 2013 at 11:59 UTC ( #1052697=perlquestion: print w/replies, xml ) Need Help??
varalaxmibbnl has asked for the wisdom of the Perl Monks concerning the following question:

if i run this code i get (Can't locate JSON.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at map.pl line 3. BEGIN failed--compilation aborted at map.pl line 3.) this error.... i don't understand what is the problem in this plz help me out for this

use strict; use LWP::Simple; # from CPAN use JSON qw( decode_json ); # from CPAN sub getLatLong($){ my ($address) = @_; my $format = "json"; #can also to 'xml' my $geocodeapi = "https://maps.googleapis.com/maps/api/geocode/"; my $url = $geocodeapi . $format . "?sensor=false&address=" . $addres +s; my $json = get($url); my $d_json = decode_json( $json ); my $lat = $d_json->{results}->[0]->{geometry}->{location}->{lat}; my $lng = $d_json->{results}->[0]->{geometry}->{location}->{lng}; return ($lat, $lng); }

Replies are listed 'Best First'.
Re: networking with perl
by toolic (Bishop) on Sep 06, 2013 at 12:19 UTC
    This error is telling you that the JSON module cannot be found in your Perl search path directories (@INC). Most likely, you did not install it; to do so, you could use cpan.

    Or, maybe you did install it, but you need to point to it: see PERL5LIB.

Re: networking with perl
by daxim (Chaplain) on Sep 06, 2013 at 13:30 UTC
    Since your @INC includes /etc/perl, I guess you are running a Debian system, or one derived from it. Install the package libjson-perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1052697]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2016-10-01 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.