dcdb90d2e57d20b992ec9c251f09e148e579fb38
[ZOOM-Perl-moved-to-github.git] / samples / zoom / zoomscan.pl
1 # $Id: zoomscan.pl,v 1.1 2007-08-15 18:36:36 mike Exp $
2 #
3 # This is the scanning counterpart to zoomscan.pl's searching
4 # perl -I../../blib/lib -I../../blib/arch zoomscan.pl <target> <scanQuery>
5
6 use strict;
7 use warnings;
8 use ZOOM;
9
10 if (@ARGV != 2) {
11     print STDERR "Usage: $0 target scanQuery\n";
12     print STDERR "      eg. $0 z3950.indexdata.dk/gils computer\n";
13     exit 1;
14 }
15 my($host, $scanQuery) = @ARGV;
16
17 eval {
18     my $conn = new ZOOM::Connection($host, 0);
19     $conn->option(preferredRecordSyntax => "usmarc");
20     my $ss = $conn->scan_pqf($scanQuery);
21     my $n = $ss->size();
22     for my $i (0..$n-1) {
23         my($term, $occ) = $ss->term($i);
24         print $i+1, ": $term";
25         print " ($occ)" if defined $occ;
26         print "\n";
27     }
28     
29     $ss->destroy();
30     $conn->destroy();
31 }; if ($@) {
32     die "Non-ZOOM error: $@" if !$@->isa("ZOOM::Exception");
33     print STDERR "ZOOM error $@\n";
34     exit 1;
35 }