sztest: Use bash specifically.
[utils.git] / anndata
CommitLineData
5364a3ac 1#!/usr/bin/perl -w
2
5364a3ac 3use Getopt::Long;
639d9800 4use Anime::ANN;
5364a3ac 5
36bbb0ca 6binmode STDOUT, ":utf8";
b7ae13c0 7GetOptions(\%options, "l=s", "b=s") || exit 1;
5364a3ac 8
9if($options{"l"}) {
639d9800 10 @list = Anime::ANN::getlist($options{"l"});
5364a3ac 11 foreach $name (@list) {
12 print "$name\n";
13 }
14 exit 0;
15}
16
639d9800 17if($options{"b"}) {
b7ae13c0 18 $id = Anime::ANN::getid $options{"b"};
19 if(defined($id)) {
20 exec "htmlview", Anime::ANN::geturl($id);
21 } else {
22 printf STDERR "could not find " . $options{"b"} . "\n";
23 exit 1;
24 }
639d9800 25}
26
27if(!defined($ARGV[0])) {
28 printf STDERR "usage: anndata NAME\n";
29 exit 1;
30}
31
32unless($id = Anime::ANN::getid $ARGV[0]) {
5364a3ac 33 printf STDERR "could not find $ARGV[0]\n";
34 exit 1;
35}
36
639d9800 37$info = Anime::ANN::getseries $id;
38
39sub refdump
40{
41 my($ref, $ind);
42 ($ref, $ind) = @_;
43 if(!defined($ind)) {
44 $ind = 0;
45 }
46
47 if(ref $ref eq "HASH") {
48 for $key (sort keys %{$ref}) {
49 print ((" " x $ind) . "$key: " . (" " x (20 - length $key)) . "(" . $ref->{$key} . ")\n");
50 refdump($ref->{$key}, $ind + 1) if ref $ref->{$key};
51 }
52 } elsif(ref $ref eq "ARRAY") {
53 for($i = 0; $i < @{$ref}; $i++) {
54 print ((" " x $ind) . "$i: " . $ref->[$i] . "\n");
55 refdump($ref->[$i], $ind + 1) if ref $ref->[$i];
56 }
b7ae13c0 57 } elsif(ref $ref eq "SCALAR") {
58 print ((" " x $ind) . $$ref . "\n");
639d9800 59 } else {
60 print ((" " x $ind) . "Unknown ref: $ref\n");
61 }
62}
5364a3ac 63
639d9800 64refdump $info;