Sha256: 0629a2faef25116a1864a1c345a19d3fddc16d0d956dcff0e85e993f70f185df

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/perl -CSD
use strict;
use FindBin;

use lib "$FindBin::Bin/HeaderParseService/lib";

use HeaderParse::API::Parser;
use HeaderParse::Config::API_Config;

my $argc = scalar(@ARGV);

if ($argc != 2) {
  print "Usage: ./extract.pl path_to_input path_to_output\n";
  exit 1;
}

my $inputPath = $ARGV[0];
my $outputPath = $ARGV[1];

import($inputPath, $outputPath);

exit;

sub import {
    my ($filePath, $id) = @_;

    system("mkdir","-p","$id");
    
    my ($status, $msg) = prep($filePath, $id);
    if ($status == 0) {
	    print STDERR "$id: $msg\n";
    }
    if ($status == 1) {
	    print STDOUT "$id\n";
    }
}


sub prep {
    my ($textFile, $id) = @_;

    my ($ehstatus, $msg) = extractHeader($textFile, $id);
    if ($ehstatus <= 0) {
	    return ($ehstatus, $msg);
    }    

    return (1, "");
}

sub extractHeader {
    my ($textFile, $id) = @_;

    my $jobID;
    while($jobID = rand(time)) {
	unless(-f $offlineD."$jobID") {
	    last;
	}
    }

    my ($status, $msg, $rXML) =
	HeaderParse::API::Parser::_parseHeader($textFile, $jobID);

    if ($status <= 0) {
	return ($status, $msg);
    }

    unless(open(HEAD, ">:utf8", "$outputPath/out.header")) {
	return (0, "Unable to open header file: $!");
    }

    print HEAD $$rXML;
    close HEAD;
    return (1);

}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
biblicit-2.1.0 svm-header-parse/extract.pl
biblicit-2.0.8 svm-header-parse/extract.pl
biblicit-2.0.7 svm-header-parse/extract.pl
biblicit-2.0.6 svm-header-parse/extract.pl
biblicit-2.0.5 svm-header-parse/extract.pl
biblicit-2.0.4 svm-header-parse/extract.pl
biblicit-2.0.3 svm-header-parse/extract.pl