anndl: Fixed a couple of bugs.
[utils.git] / anndata
diff --git a/anndata b/anndata
index 3cda2c2..7ed3e13 100755 (executable)
--- a/anndata
+++ b/anndata
@@ -3,7 +3,8 @@
 use Getopt::Long;
 use Anime::ANN;
 
-GetOptions(\%options, ("l=s", "b=s"));
+binmode STDOUT, ":utf8";
+GetOptions(\%options, "l=s", "b=s", "d") || exit 1;
 
 if($options{"l"}) {
     @list = Anime::ANN::getlist($options{"l"});
@@ -13,8 +14,20 @@ if($options{"l"}) {
     exit 0;
 }
 
+$browse = "";
 if($options{"b"}) {
-    exec "htmlview", Anime::ANN::geturl(Anime::ANN::getid $options{"b"});
+    $browse = $options{"b"};
+} elsif($options{"d"}) {
+    $browse = `basename "\$(pwd)"`;
+}
+if($browse) {
+    $id = Anime::ANN::getid $browse;
+    if(defined($id)) {
+       exec "htmlview", Anime::ANN::geturl($id);
+    } else {
+       printf STDERR "could not find " . $browse . "\n";
+       exit 1;
+    }
 }
 
 if(!defined($ARGV[0])) {
@@ -47,10 +60,11 @@ sub refdump
            print (("  " x $ind) . "$i: " . $ref->[$i] . "\n");
            refdump($ref->[$i], $ind + 1) if ref $ref->[$i];
        }
+    } elsif(ref $ref eq "SCALAR") {
+       print (("  " x $ind) . $$ref . "\n");
     } else {
        print (("  " x $ind) . "Unknown ref: $ref\n");
     }
 }
 
-binmode STDOUT, ":utf8";
 refdump $info;