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