in reply to pl script in webserver

Here is a nifty little script i put together for someone that was having problems like yours

#!/usr/bin/perl use strict; use warnings; print "content-type: text/plain\n\nTesting Use commands\n\n"; #addin('Data::Dumper'); #addin('strict');addin('warnings'); #addin('Config');addin('Fcntl'); #addin('CGI::Carp qw(fatalsToBrowser)'); #addin('GD'); #addin('LWP::UserAgent'); addin('JSON'); addin('x::x'); sub addin { my $mod=shift; my $pre=shift; my %inc0=%INC; if ($pre) {print '<pre>'."\n";} print "\n"; print 'new to %INC from adding use '.$mod."\n"; eval 'use '.$mod.';' ; print 'eval use ERROR:'.$@."\n" if ($@); my %incnew=(); my $max=0; # this ends up as largest in %INC not largest that is new + , good nuf for my $k (keys %INC) { $max=length($k) if (length($k)>$max);} my $fmt=' %-'.$max.'s => %s'."\n"; for my $k (sort keys(%INC)) { printf $fmt,$k,$INC{$k} unless ($inc0{$k}); } if ($pre) {print '</pre>'."\n";} }
It is customized for your JSON instance, but you can put in any lines to load anymodule you like, as the comment out lines show.

It will either display what gets added to your program when a use statment is executed, or an error message like my example of x::x shows.

result for my server
Testing Use commands new to %INC from adding use JSON Carp.pm => /usr/share/perl/5.18/Carp.pm Exporter.pm => /usr/share/perl/5.18/Exporter.pm Exporter/Heavy.pm => /usr/share/perl/5.18/Exporter/Heavy.pm JSON.pm => /usr/share/perl5/JSON.pm JSON/XS.pm => /usr/lib/perl5/JSON/XS.pm XSLoader.pm => /usr/share/perl/5.18/XSLoader.pm attributes.pm => /usr/lib/perl/5.18/attributes.pm base.pm => /usr/share/perl/5.18/base.pm common/sense.pm => /usr/lib/perl5/common/sense.pm constant.pm => /usr/share/perl/5.18/constant.pm overload.pm => /usr/share/perl/5.18/overload.pm overloading.pm => /usr/share/perl/5.18/overloading.pm vars.pm => /usr/share/perl/5.18/vars.pm warnings/register.pm => /usr/share/perl/5.18/warnings/register.pm new to %INC from adding use x::x eval use ERROR:Can't locate x/x.pm in @INC (you may need to install th +e x::x module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 / +usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/ +perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at (eval 8 +) line 1. BEGIN failed--compilation aborted at (eval 8) line 1.
Hope it helps.

Replies are listed 'Best First'.
Re^2: pl script in webserver
by bigup401 (Pilgrim) on Apr 08, 2017 at 21:13 UTC

    huck i tried your script and got the response. so how to fix it

    new to %INC from adding use Data::Dumper Data/Dumper.pm => /usr/lib64/perl5/Data/Dumper.pm bytes.pm => /usr/share/perl5/bytes.pm new to %INC from adding use strict new to %INC from adding use warnings new to %INC from adding use Config new to %INC from adding use Fcntl new to %INC from adding use CGI::Carp qw(fatalsToBrowser) CGI/Carp.pm => /usr/share/perl5/CGI/Carp.pm File/Spec.pm => /usr/lib64/perl5/File/Spec.pm File/Spec/Unix.pm => /usr/lib64/perl5/File/Spec/Unix.pm new to %INC from adding use GD FileHandle.pm => /usr/share/perl5/FileHandle.pm GD.pm => /usr/local/lib64/perl5/GD.pm GD/Image.pm => /usr/local/lib64/perl5/GD/Image.pm GD/Polygon.pm => /usr/local/lib64/perl5/GD/Polygon.pm IO/File.pm => /usr/lib64/perl5/IO/File.pm IO/Seekable.pm => /usr/lib64/perl5/IO/Seekable.pm new to %INC from adding use LWP::UserAgent new to %INC from adding use JSON JSON.pm => /usr/local/share/perl5/JSON.pm new to %INC from adding use x::x eval use ERROR:Can't locate x/x.pm in @INC (@INC contains: /home/breflf/perl5/lib/perl5 /home/breflf/perl5/lib/perl5/x86_64-linux-thread-multi /home/breflf/perl/usr/local/lib64/perl5 /home/breflf/perl/usr/local/share/perl5 /home/breflf/perl/usr/lib64/perl5/vendor_perl /home/breflf/perl/usr/share/perl5/vendor_perl /home/breflf/perl/usr/lib64/perl5 /home/breflf/perl/usr/share/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 25) line 1. BEGIN failed--compilation aborted at (eval 25) line 1. Carp/Heavy.pm => /usr/share/perl5/Carp/Heavy.pm

      The failure on x::x was just to show you how a failure would printout. You can ignore it.

      JSON loaded fine for you. On mine loading JSON also loads JSON::XS. Yours didnt.

      Try the one below at Re: pl script in webserver and enter JSON::XS into the box. Add JSON::PP too. I bet it shows a failure on JSON::XS, that means you dont have JSON::XS. If it doesnt show a failure on JSON:PP use that instead.

      Edit to add: Interesting that LWP::UserAgent didnt fail, but didnt add anything either, as if it was already loaded for some reason.

        i finally fixed it. but we really lack good hosting isp for perl. i had to buy vps and host the script myself. most isp they employe php javascript lets say web developers. when it comes to perl or python errors and modules. they act innocent. and they dont give root access for the account to fix. lol for security purpose