Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

networking with perl

by varalaxmibbnl (Acolyte)
on Sep 06, 2013 at 11:59 UTC ( [id://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 (Curate) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-03-29 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found