3 # $Id: zoomscan.pl,v 1.5 2008-05-14 13:27:32 mike Exp $
5 # This is the scanning counterpart to zoomscan.pl's searching
6 # perl -I../../blib/lib -I../../blib/arch zoomscan.pl <target> <scanQuery>
8 # For example (using Z39.50 and SRW, Type-1 and CQL):
9 # perl zoomscan.pl tcp:localhost:8018/IR-Explain---1 '@attr 1=dc.title the'
10 # perl zoomscan.pl http://localhost:8018/IR-Explain---1 '@attr 1=dc.title the'
11 # perl zoomscan.pl -q http://localhost:8018/IR-Explain---1 'dc.title=the'
19 if (!getopts('q', \%opts) || @ARGV != 2) {
20 print STDERR "Usage: $0 [options] target scanQuery
21 -q Query is CQL [default: PQF]
22 eg. $0 z3950.indexdata.dk/gils computer\n";
26 my($host, $scanQuery) = @ARGV;
29 my $conn = new ZOOM::Connection($host, 0);
30 $conn->option(preferredRecordSyntax => "usmarc");
31 ### Could use ZOOM::Query::CQL below, but that only works in SRU/W.
32 my $q = $opts{q} ? new ZOOM::Query::CQL($scanQuery) :
33 new ZOOM::Query::PQF($scanQuery);
34 my $ss = $conn->scan($q);
37 my($term, $occ) = $ss->term($i);
38 print $i+1, ": $term";
39 print " ($occ)" if defined $occ;
46 die "Non-ZOOM error: $@" if !$@->isa("ZOOM::Exception");
47 print STDERR "ZOOM error $@\n";