http://www.perlmonks.org?node_id=1184949


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