sztest: Use bash specifically.
[utils.git] / anndata
... / ...
CommitLineData
1#!/usr/bin/perl -w
2
3use Getopt::Long;
4use Anime::ANN;
5
6binmode STDOUT, ":utf8";
7GetOptions(\%options, "l=s", "b=s") || exit 1;
8
9if($options{"l"}) {
10 @list = Anime::ANN::getlist($options{"l"});
11 foreach $name (@list) {
12 print "$name\n";
13 }
14 exit 0;
15}
16
17if($options{"b"}) {
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 }
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]) {
33 printf STDERR "could not find $ARGV[0]\n";
34 exit 1;
35}
36
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 }
57 } elsif(ref $ref eq "SCALAR") {
58 print ((" " x $ind) . $$ref . "\n");
59 } else {
60 print ((" " x $ind) . "Unknown ref: $ref\n");
61 }
62}
63
64refdump $info;