File: bor_info-sec.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 (69 lines) | stat: -rw-r--r-- 1,296 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env perl
use FindBin;
use lib "$FindBin::Bin/../lib";
use Catmandu::Sane;
use Catmandu::AlephX;
use open qw(:std :utf8);
use Data::Dumper;

sub read_str {
  my $line = <STDIN>;
  chomp $line;
  $line;
}
sub read_password {
    use Term::ReadKey;
    ReadMode 'noecho';
    my $password = ReadLine 0;
    ReadMode 'normal';
    chomp $password;
    print "\n";
    return $password;
}

my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X");

my $file = "-";
my($library,$bor_id,$verification);

print "library: ";
$library = read_str();

print "bor_id: ";
$bor_id = read_str();

print "verification: ";
$verification = read_password();

print "file: ";
$file = read_str();
$file = "/dev/stdout" if $file eq "-";

open STDOUT,">:utf8",$file or die($!);

my %args = (
  library => $library,
  bor_id => $bor_id,
  verification => $verification,
  loans => 'P'
);
my $info = $aleph->bor_info(%args);
if($info->is_success){

  for my $type(qw(z303 z304 z305)){
    say "$type:";
    my $data = $info->$type();
    for my $key(keys %$data){
      say "\tkey: $key";
      say "\t$key : $data->{$key}" if $data->{$key};
    }
  }
  say "fine:";
  print Dumper($info->fine);

  print Dumper($info->item_l);

}else{
  say STDERR "error: ".join('',@{$info->errors});
  exit 1;
}