Reputation: 21
I want to run a perl script which uses JSON on my website. I've tested the following script in the cgi-bin folder with success:
#!/usr/local/bin/perl
print "Content-Type: text/html \n\n";
print "<h1 align=center>\n";
print "Welcome to my website\n";
print "</h1>\n";
But as soon as I include the JSON module, the website's CMS (OpenCart) reverts to a "Page cannot be found" error:
#!/usr/local/bin/perl
use JSON;
print "Content-Type: text/html \n\n";
print "<h1 align=center>\n";
print "Welcome to my website\n";
print "</h1>\n";
A rep from the website host confirmed JSON is installed on the (linux) server
Am I using the correct syntax to include JSON in my script?
Upvotes: 1
Views: 231
Reputation: 21
DVK commented:
Also, check if you have JSON or JSON::PP installed (the latter was in the core Perl since 5.14):
perl -MJSON -e ''
andperl -MJSON::PP -e ''
Thanks DVK, if I include use JSON::PP
instead of use JSON
, the perl script works.
I had to change some JSON-specific functions to JSON::PP functions (ie. change $json->objToJson
to $json->encode
) for it to work with JSON::PP.
This link also provided some help
Upvotes: 1