File: store_add.pl

package info (click to toggle)
libcatmandu-alephx-perl 1.073-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 688 kB
  • sloc: perl: 2,616; xml: 71; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 597 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env perl
use FindBin;
use lib "$FindBin::Bin/../lib";
use Catmandu::Sane;
use Catmandu::Util qw(:is);
use Catmandu::Store::AlephX;
use Catmandu::Importer::MARC;
use Data::Dumper;
use open qw(:std :utf8);

my $file = shift;
if(is_string($file) && -f $file){
  open STDIN,"<",$file or die($!);
}
my $importer = Catmandu::Importer::MARC->new(type => "ALEPHSEQ");
my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X",username => "t",password => "t")->bag();

$importer->each(sub{
  my $r = shift;
  delete $r->{_id};
  $r = $bag->add($r);
  say "added ".$r->{_id};
});