1. Various detail changes to remove some more warning with -w on
[spider.git] / perl / DXCommandmode.pm
index e429654c3de92d592955f5da5623ff58564b3383..de59160663c080356a11a354c5a52b098f0f3ea1 100644 (file)
@@ -199,20 +199,25 @@ sub run_cmd
                        ($path, $fcmd) = search($main::localcmd, $cmd, "pl");
                        ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
 
-                       dbg('command', "path: $cmd cmd: $fcmd");
+                       if ($path && $cmd) {
+                               dbg('command', "path: $cmd cmd: $fcmd");
                        
-                       my $package = find_cmd_name($path, $fcmd);
-                       @ans = (0) if !$package ;
-                       
-                       if ($package) {
-                               dbg('command', "package: $package");
+                               my $package = find_cmd_name($path, $fcmd);
+                               @ans = (0) if !$package ;
                                
-                               my $c = qq{ \@ans = $package(\$self, \$args) };
-                               dbg('eval', "cluster cmd = $c\n");
-                               eval  $c;
-                               if ($@) {
-                                       @ans = (0, "Syserr: Eval err cached $package\n$@");
+                               if ($package) {
+                                       dbg('command', "package: $package");
+                                       
+                                       my $c = qq{ \@ans = $package(\$self, \$args) };
+                                       dbg('eval', "cluster cmd = $c\n");
+                                       eval  $c;
+                                       if ($@) {
+                                               @ans = (0, "Syserr: Eval err cached $package\n$@");
+                                       }
                                }
+                       } else {
+                               dbg('command', "cmd: $cmd not found");
+                               @ans = (0);
                        }
                }
        }
@@ -467,7 +472,7 @@ sub find_cmd_name {
        
        # return if we can't find it
        $errstr = undef;
-       if (undef $mtime) {
+       unless (defined $mtime) {
                $errstr = DXM::msg('e1');
                return undef;
        }
@@ -478,6 +483,8 @@ sub find_cmd_name {
                #print STDERR "already compiled $package->handler\n";
                ;
        } else {
+               delete_package($package) if defined $Cache{$package}{mtime};
+               
                my $fh = new FileHandle;
                if (!open $fh, $filename) {
                        $errstr = "Syserr: can't open '$filename' $!";
@@ -488,11 +495,7 @@ sub find_cmd_name {
                close $fh;
                
                #wrap the code into a subroutine inside our unique package
-               my $eval = qq{ 
-                       sub $package 
-                       { 
-                        $sub 
-                       } };
+               my $eval = qq{ sub $package { $sub } };
                
                if (isdbg('eval')) {
                        my @list = split /\n/, $eval;
@@ -514,7 +517,7 @@ sub find_cmd_name {
                        delete_package($package);
                } else {
                        #cache it unless we're cleaning out each time
-                       $Cache{$package}{mtime} = $mtime;
+                       $Cache{$package}{'mtime'} = $mtime;
                }
        }