36cf3e405b0640a7e457f51d8efd3f5ef5af56e3
[irspy-moved-to-github.git] / bin / irspy-dump.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use warnings;
5 use ZOOM;
6
7 if (@ARGV != 1) {
8     print STDERR "Usage: $0 target\n";
9     exit 1;
10 }
11
12 my $conn = new ZOOM::Connection($ARGV[0]);
13 $conn->option(preferredRecordSyntax => "xml");
14 $conn->option(elementSetName => "zebra::data");
15 my $rs = $conn->search_pqf('@attr 1=_ALLRECORDS @attr 2=103 ""');
16 my $n = $rs->size();
17 $| = 1;
18 print "$0: dumping $n records\n";
19 foreach my $i (1..$n) {
20     print ".";
21     print " $i/$n (", int($i*100/$n), "%)\n" if $i % 50 == 0;
22     my $rec = $rs->record($i-1);
23     my $xml = $rec->render();
24     open F, ">$i.xml";
25     print F $xml;
26     close F;
27 }
28 print " $n/$n (100%)\n" if $n % 50 != 0;
29 print "complete\n";