Remove extraneous and misleading old CVS IDs
[ZOOM-Perl-moved-to-github.git] / samples / zoom / zoomtst1.pl
1 #!/usr/bin/perl -w
2
3 # See ../README for a description of this program.
4 # perl -I../../blib/lib -I../../blib/arch zoomtst1.pl <target> <query>
5
6 use strict;
7 use warnings;
8 use ZOOM;
9
10 if (@ARGV < 2 || @ARGV %2 == 1) {
11     print STDERR "Usage: $0 target query [<option> <value> ...]\n";
12     print STDERR "      eg. $0 z3950.indexdata.dk/gils computer\n";
13     exit 1;
14 }
15 my $host = shift(@ARGV);
16 my $query = shift(@ARGV);
17
18 eval {
19     my $conn = new ZOOM::Connection($host, 0);
20     $conn->option(preferredRecordSyntax => "usmarc");
21     while (@ARGV) {
22         my $key = shift(@ARGV);
23         my $value = shift(@ARGV);
24         $conn->option($key => $value);
25     }
26
27     my $rs = $conn->search_pqf($query);
28     my $n = $rs->size();
29     print "Query '$query' found $n records\n";
30     for my $i (0..$n-1) {
31         my $rec = $rs->record($i);
32         print "=== Record ", $i+1, " of $n ===\n";
33         print $rec->render();
34     }
35     
36     $rs->destroy();
37     $conn->destroy();
38 }; if ($@) {
39     die "Non-ZOOM error: $@" if !$@->isa("ZOOM::Exception");
40     print STDERR "Error ", $@->code(), ": ", $@->message();
41     print STDERR " (", $@->addinfo(), ")" if $@->addinfo();
42     print STDERR "\n";
43     exit 1;
44 }