Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: GD and LWP giving 500 errors

by huck (Parson)
on Mar 17, 2017 at 01:51 UTC ( #1184949=note: print w/replies, xml ) Need Help??


in reply to Re^2: GD and LWP giving 500 errors
in thread GD and LWP giving 500 errors

more fancy

use strict; use warnings; print "content-type: text/plain\n\nTesting"; no warnings 'once' ; local $Data::Dumper::Sortkeys=1; local $Data::Dumper::Indent=3; use warnings; addin('Data::Dumper',1); addin('CGI::Carp qw(fatalsToBrowser)',1); addin('GD',1); addin('LWP::UserAgent',1); addin('x::x',1); sub addin_old { my $mod=shift; my $pre=shift; my %inc0=%INC; if ($pre) {print '<pre>'."\n";} eval 'use '.$mod.';' ; print 'eval use ERROR:'.$@."\n" if ($@); my %incnew=(); for my $k (keys %INC) { $incnew{$k}=$INC{$k} unless ($inc0{$k}); } print 'new to %INC from adding use '.$mod."\n"; print Dumper(\%incnew); if ($pre) {print '</pre>'."\n";} } sub addin { my $mod=shift; my $pre=shift; my %inc0=%INC; if ($pre) {print '<pre>'."\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"; print 'new to %INC from adding use '.$mod."\n"; for my $k (sort keys(%INC)) { printf $fmt,$k,$INC{$k} unless ($inc0{$k}); } if ($pre) {print '</pre>'."\n";} }
result (to term)
content-type: text/plain Testing<pre> new to %INC from adding use Data::Dumper $VAR1 = { 'Carp.pm' => 'C:/Perl/lib/Carp.pm', 'Data/Dumper.pm' => 'C:/Perl/lib/Data/Dumper.pm', 'Exporter.pm' => 'C:/Perl/lib/Exporter.pm', 'XSLoader.pm' => 'C:/Perl/lib/XSLoader.pm', 'bytes.pm' => 'C:/Perl/lib/bytes.pm', 'constant.pm' => 'C:/Perl/lib/constant.pm', 'overload.pm' => 'C:/Perl/lib/overload.pm', 'overloading.pm' => 'C:/Perl/lib/overloading.pm', 'vars.pm' => 'C:/Perl/lib/vars.pm', 'warnings/register.pm' => 'C:/Perl/lib/warnings/register.pm' }; </pre> <pre> new to %INC from adding use CGI::Carp qw(fatalsToBrowser) $VAR1 = { 'ActivePerl/Config.pm' => 'C:/Perl/lib/ActivePerl/Config.pm' +, 'CGI/Carp.pm' => 'C:/Perl/site/lib/CGI/Carp.pm', 'Config.pm' => 'C:/Perl/lib/Config.pm', 'Config_git.pl' => 'C:/Perl/lib/Config_git.pl', 'Config_heavy.pl' => 'C:/Perl/lib/Config_heavy.pl', 'DynaLoader.pm' => 'C:/Perl/lib/DynaLoader.pm', 'File/Spec.pm' => 'C:/Perl/lib/File/Spec.pm', 'File/Spec/Unix.pm' => 'C:/Perl/lib/File/Spec/Unix.pm', 'File/Spec/Win32.pm' => 'C:/Perl/lib/File/Spec/Win32.pm', 'deprecate.pm' => 'C:/Perl/lib/deprecate.pm', 'if.pm' => 'C:/Perl/lib/if.pm' }; </pre> <pre> new to %INC from adding use GD $VAR1 = { 'AutoLoader.pm' => 'C:/Perl/lib/AutoLoader.pm', 'Fcntl.pm' => 'C:/Perl/lib/Fcntl.pm', 'FileHandle.pm' => 'C:/Perl/lib/FileHandle.pm', 'GD.pm' => 'C:/Perl/lib/GD.pm', 'GD/Image.pm' => 'C:/Perl/lib/GD/Image.pm', 'GD/Polygon.pm' => 'C:/Perl/lib/GD/Polygon.pm', 'IO.pm' => 'C:/Perl/lib/IO.pm', 'IO/File.pm' => 'C:/Perl/lib/IO/File.pm', 'IO/Handle.pm' => 'C:/Perl/lib/IO/Handle.pm', 'IO/Seekable.pm' => 'C:/Perl/lib/IO/Seekable.pm', 'SelectSaver.pm' => 'C:/Perl/lib/SelectSaver.pm', 'Symbol.pm' => 'C:/Perl/lib/Symbol.pm' }; </pre> <pre> new to %INC from adding use LWP::UserAgent $VAR1 = { 'Exporter/Heavy.pm' => 'C:/Perl/lib/Exporter/Heavy.pm', 'HTTP/Date.pm' => 'C:/Perl/lib/HTTP/Date.pm', 'HTTP/Headers.pm' => 'C:/Perl/lib/HTTP/Headers.pm', 'HTTP/Message.pm' => 'C:/Perl/lib/HTTP/Message.pm', 'HTTP/Request.pm' => 'C:/Perl/lib/HTTP/Request.pm', 'HTTP/Response.pm' => 'C:/Perl/lib/HTTP/Response.pm', 'HTTP/Status.pm' => 'C:/Perl/lib/HTTP/Status.pm', 'LWP.pm' => 'C:/Perl/lib/LWP.pm', 'LWP/MemberMixin.pm' => 'C:/Perl/lib/LWP/MemberMixin.pm', 'LWP/Protocol.pm' => 'C:/Perl/lib/LWP/Protocol.pm', 'LWP/UserAgent.pm' => 'C:/Perl/lib/LWP/UserAgent.pm', 'Storable.pm' => 'C:/Perl/lib/Storable.pm', 'Time/Local.pm' => 'C:/Perl/lib/Time/Local.pm', 'URI.pm' => 'C:/Perl/lib/URI.pm', 'URI/Escape.pm' => 'C:/Perl/lib/URI/Escape.pm' }; </pre> <pre> eval use ERROR:Can't locate x/x.pm in @INC (you may need to install th +e x::x module) (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at (ev +al 11) line 1. BEGIN failed--compilation aborted at (eval 11) line 1. new to %INC from adding use x::x $VAR1 = {}; </pre>

Edit to add:

interesting there are two modules LWP and GD share

'Config.pm' => 'C:/Perl/lib/Config.pm', 'Fcntl.pm' => 'C:/Perl/lib/Fcntl.pm',
adding
addin('Config',1); addin('Fcntl',1);
below  addin('Data::Dumper',1); may identify your problem, but both are core

edit2: just noticed CGI::Carp qw(fatalsToBrowser) brought in Config, and that worked it seems

Edit 3: fixed addin so Dump::Dumper doesnt have to be the first one added, left old as addin_old but it can be deleted if ya want

Replies are listed 'Best First'.
Re^4: GD and LWP giving 500 errors
by Schmunzie (Sexton) on Mar 17, 2017 at 11:49 UTC
    I can't claim I really understand what your code is doing but I tried it...

    With perlml in the shebang, it gave a 500 error.

    With just perl, it gave
    Testing<pre> new to %INC from adding use Data::Dumper Carp.pm => /usr/share/perl5/vendor_perl/Carp.pm Data/Dumper.pm => /usr/lib64/perl5/vendor_perl/Data/Dumper.pm Exporter.pm => /usr/share/perl5/vendor_perl/Exporter.pm XSLoader.pm => /usr/share/perl5/XSLoader.pm bytes.pm => /usr/share/perl5/bytes.pm constant.pm => /usr/share/perl5/vendor_perl/constant.pm overload.pm => /usr/share/perl5/overload.pm overloading.pm => /usr/share/perl5/overloading.pm vars.pm => /usr/share/perl5/vars.pm warnings/register.pm => /usr/share/perl5/warnings/register.pm </pre> <pre> eval use ERROR:Can't locate CGI/Carp.pm in @INC (@INC contains: /usr/l +ocal/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl +/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at +(eval 2) line 1. BEGIN failed--compilation aborted at (eval 2) line 1. new to %INC from adding use CGI::Carp qw(fatalsToBrowser) </pre> <pre> eval use ERROR:Can't locate GD.pm in @INC (@INC contains: /usr/local/l +ib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/s +hare/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval +3) line 1. BEGIN failed--compilation aborted at (eval 3) line 1. new to %INC from adding use GD </pre> <pre> new to %INC from adding use LWP::UserAgent Config.pm => /usr/lib64/perl5/Config.pm Exporter/Heavy.pm => /usr/share/perl5/vendor_perl/Exporter/Heavy. +pm Fcntl.pm => /usr/lib64/perl5/Fcntl.pm HTTP/Date.pm => /usr/share/perl5/vendor_perl/HTTP/Date.pm HTTP/Headers.pm => /usr/share/perl5/vendor_perl/HTTP/Headers.pm HTTP/Message.pm => /usr/share/perl5/vendor_perl/HTTP/Message.pm HTTP/Request.pm => /usr/share/perl5/vendor_perl/HTTP/Request.pm HTTP/Response.pm => /usr/share/perl5/vendor_perl/HTTP/Response.p +m HTTP/Status.pm => /usr/share/perl5/vendor_perl/HTTP/Status.pm LWP.pm => /usr/share/perl5/LWP.pm LWP/MemberMixin.pm => /usr/share/perl5/LWP/MemberMixin.pm LWP/Protocol.pm => /usr/share/perl5/LWP/Protocol.pm LWP/UserAgent.pm => /usr/share/perl5/LWP/UserAgent.pm Storable.pm => /usr/lib64/perl5/vendor_perl/Storable.pm Time/Local.pm => /usr/share/perl5/vendor_perl/Time/Local.pm URI.pm => /usr/share/perl5/URI.pm URI/Escape.pm => /usr/share/perl5/URI/Escape.pm </pre> <pre> eval use ERROR:Can't locate x/x.pm in @INC (@INC contains: /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 + 7) line 1. BEGIN failed--compilation aborted at (eval 7) line 1. new to %INC from adding use x::x </pre>

      If you want to try again under perlml strike the following line

      use strict; use warnings;
      those are the only non evaled use statments. if it works, whew.

      otherwise it looks like LWP came in, but CGI/Carp and GD didnt

      you can strike addin('x::x',1); too. that was just there to display how a nonfound module would behave, and you got those.

      You could try adding addin('LWP::Simple',1); to see if it can find that.

      What it is doing is running the use statments under an eval. eval will trap the die preventing the script from issueing an error at that point and dieing. Since dieing means no output is sent back thats why you got the 500. It also lists all the modules added by that use statment. Since one module can use many others it can be quite informative.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2019-09-17 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (199 votes). Check out past polls.

    Notices?