marchello has asked for the wisdom of the Perl Monks concerning the following question:
This is how I think it should look in perl:CREATE OR REPLACE FUNCTION get(uri character varying) RETURNS json AS $BODY$ import urllib2 data = urllib2.urlopen(uri) return data.read() $BODY$ LANGUAGE plpython2u VOLATILE COST 100;
But when I try to run my perl function it returns error:CREATE OR REPLACE FUNCTION get(input_url character varying) RETURNS json AS $BODY$ use warnings; import LWP::Simple; my $url = input_url; my $content = get($url); $content =~ s/ /%20/g; return $content; $BODY$ LANGUAGE plperl VOLATILE COST 100;
Please advise.select get('ipinfo.io/ip'); ERROR: Undefined subroutine &main::get called at line 6. CONTEXT: PL/Perl function "get" ********** Error ********** ERROR: Undefined subroutine &main::get called at line 6. SQL state: 38000 Context: PL/Perl function "get"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: plperl (postgreSQL perl) get url function
by LanX (Saint) on May 27, 2019 at 21:58 UTC | |
by marchello (Novice) on May 27, 2019 at 22:24 UTC | |
by poj (Abbot) on May 28, 2019 at 12:45 UTC | |
by LanX (Saint) on May 27, 2019 at 22:37 UTC | |
by marchello (Novice) on May 28, 2019 at 16:25 UTC | |
|
Re: plperl (postgreSQL perl) get url function
by karlgoethebier (Abbot) on May 28, 2019 at 13:01 UTC |