Re[2]: problem with 'die' and UserAgent

Enrique S. Yambao (eyambao@mail.asiandevbank.org)
Tue, 10 Sep 96 08:20:08 +800


     Hi Gisle,
     
     I lost the listserve address of this mailing list. I want to 
     unsubscribe to this list.  Can you help me???
     
     Thanks for your help,
     Eric


______________________________ Reply Separator _________________________________
Subject: Re: problem with 'die' and UserAgent 
Author:  Gisle Aas <aas@bergen.sn.no> at INTERNET
Date:    9/9/96 5:45 PM


In message <199609081845.OAA12931@jander.com>, Jim Anderson writes: 
> The following code produces this error:
> 
> Can't locate auto/LWP/UserAgent/DESTROY.al in @INC (in cleanup) Can't loca 
te auto/LWP/UserAgent/DESTROY.al in @INC at ./test2.pl line 18
> 
> ===================================================================== 
> #!/usr/bin/perl
> 
> use LWP::UserAgent;
> 
> eval {
>   my $ua = new LWP::UserAgent;
>   $ua->agent('test/0.1');
>     
>   my $req = new HTTP::Request POST => "http://$server/cgi-bin/srvStatus"; 
>   die "bye, bye";
> };
> 
> if ($@) {
>   chomp $@;
>   print "$@\n";
> }
> ===================================================================== 
> 
> This certainly seems like a bug. Any suggestions appreciated!
     
This is a bug in the perl5.00[23] AutoLoader.  The following code 
demonstrates the same problem:
     
   #!/usr/bin/perl
   {
     package P;
     require AutoLoader;
     @ISA=qw(AutoLoader);
     sub new { bless {} }
     # sub DESTROY {}  # workaround
   }
     
   eval{
     my $a = new P;
     die "bye, bye";
   };
   print $@ if $@;
     
     
This is a patch to the AutoLoader.pm (from 5.003) that fixes the problem:
     
--- /local/perl/lib/AutoLoader.pm Thu Feb 29 15:12:52 1996 
+++ AutoLoader.pm Mon Sep  9 09:37:41 1996
@@ -23,25 +23,30 @@
 AUTOLOAD {
     my $name = "auto/$AUTOLOAD.al";
     $name =~ s#::#/#g;
+    my $save = $@;
     eval {require $name};
     if ($@) {
- # The load might just have failed because the filename was too
- # long for some old SVR3 systems which treat long names as errors. 
- # If we can succesfully truncate a long name then it's worth a go. 
- # There is a slight risk that we could pick up the wrong file here 
- # but autosplit should have warned about that when splitting.
- if ($name =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){ 
-     eval {require $name};
- }
- elsif ($AUTOLOAD =~ /::DESTROY$/) { 
-     # eval "sub $AUTOLOAD {}";
+ if ($AUTOLOAD =~ /::DESTROY$/) {
      *$AUTOLOAD = sub {};
- }
- if ($@){
-     $@ =~ s/ at .*\n//;
-     croak $@;
+ } else {
+     # The load might just have failed because the filename was too
+     # long for some old SVR3 systems which treat long names as errors. 
+     # If we can succesfully truncate a long name then it's worth a go. 
+     # There is a slight risk that we could pick up the wrong file here 
+     # but autosplit should have warned about that when splitting.
+     if ($name =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){ 
+  eval {require $name};
+     }
+     elsif ($AUTOLOAD =~ /::DESTROY$/) { 
+  # eval "sub $AUTOLOAD {}";
+     }
+     if ($@){
+  $@ =~ s/ at .*\n//;
+  croak $@;
+     }
  }
     }
+    $@ = $save;
     $DB::sub = $AUTOLOAD; # Now debugger know where we are. 
     goto &$AUTOLOAD;
 }
     
     
Regards,
Gisle