merge isi files, with support for from-to range in filenames
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Sep 2009 18:35:50 +0000 (18:35 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 18 Sep 2009 18:35:50 +0000 (18:35 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1283 07558da8-63fa-0310-ba24-9fe276d99e06

bin/isi-merge.pl [new file with mode: 0755]

diff --git a/bin/isi-merge.pl b/bin/isi-merge.pl
new file mode 100755 (executable)
index 0000000..c7d76e6
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use autodie;
+
+my @files = @ARGV;
+@files = glob '/tmp/isi.*-*.txt' unless @files;
+
+my $path = '/tmp/isi.full.txt';
+open(my $out_fh, '>', $path);
+print $out_fh "FN ISI Export Format\nVR 1.0\n";
+
+foreach my $file ( sort {
+       my $a_r = $1 if $a =~ m{(\d+)-\d+};
+       my $b_r = $1 if $b =~ m{(\d+)-\d+};
+       $a_r <=> $b_r;
+} @files ) {
+       warn $file;
+
+       open(my $fh, '<', $file);
+       while(<$fh>) {
+               next if m/^(FN|VR|EF)/;
+
+               print $out_fh $_;
+       }
+}
+
+print $out_fh "EF\n";
+close $out_fh;
+
+warn "# $path ", -s $path;