Skip to content
Snippets Groups Projects
Select Git revision
  • 74c76d2c821b5a73886da61297cdf7f5c2440b46
  • master default protected
2 results

dcd.pl

Blame
  • dcd.pl 13.20 KiB
    #!/usr/bin/perl
    # $Id: script.pl,v 1.15 2016/09/26 10:00:50 gonter Exp $
    
    =head1 NAME
    
    DataCite DOI
    
    =head1 USAGE
    
      dcd.pl order 5   ... reserve 5 new DOIs
    
    =head1 EXAMPLES
    
      dcd.pl --ticket 14012 order 1
    
    =cut
    
    use strict;
    
    # use FindBin;
    use lib 'lib';
    
    use Data::Dumper;
    $Data::Dumper::Indent= 1;
    
    # use Module;
    use JSON;
    use Util::JSON;
    use Util::Simple_CSV;
    
    binmode( STDOUT, ':utf8' ); autoflush STDOUT 1;
    
    use Phaidra::DataCite;
    use DataCite::API;
    
    binmode( STDERR, ':utf8' ); autoflush STDERR 1;
    binmode( STDIN,  ':utf8' );
    
    my $config_file= '/etc/irma/DataCite.json';
    
    # identifiers table
    my $na_path= 'na/na-dcd-10-25365';
    my $identifiers_file= join ('/', $na_path, 'identifiers.tsv');
    
    my $ifx= '10.25365/phaidra';
    my $na_id= 1;
    my $context_id= 1;
    my $ticket;
    
    my $tsv;     # tsv object if identifiers_file is already loaded
    my $urls;    # maps urls to identifiers
    
    my $register_live= 0;
    
    my $x_flag= 0;
    
    my @PARS;
    my $arg;
    while (defined ($arg= shift (@ARGV)))
    {
      if ($arg eq '--') { push (@PARS, @ARGV); @ARGV= (); }
      elsif ($arg =~ /^--(.+)/)
      {
        my ($opt, $val)= split ('=', $1, 2);
    
           if ($opt eq 'help')   { usage(); }
        elsif ($opt eq 'ticket') { $ticket= $val || shift (@ARGV);  }
        elsif ($opt eq 'doit')   { $register_live= 1; }
        elsif ($opt eq 'prefix')
        {