6 use Digest::MD5 qw(md5_hex);
7 use Digest::SHA1 qw(sha1_hex);
8 use Data::Dump qw(dump);
10 my $use_sha1 = $ENV{SHA1} || 1;
13 @files = glob '/tmp/isi.*-*.txt' unless @files;
15 my $path = '/tmp/isi.full.txt';
17 warn "# ", $#files + 1, " files to $path sha:$use_sha1\n";
19 open(my $out_fh, '>', $path);
20 print $out_fh "FN ISI Export Format\nVR 1.0\n";
29 foreach my $file ( sort {
30 my $a_r = $1 if $a =~ m{(\d+)-\d+};
31 my $b_r = $1 if $b =~ m{(\d+)-\d+};
36 push @{ $report->{files} }, $file;
38 open(my $fh, '<', $file);
40 next if m/^(FN|VR|EF)/;
42 if ( ! m/^[\r\n]+$/s ) {
46 my $digest = $use_sha1 ? sha1_hex $rec : md5_hex $rec;
47 if ( my $times = $md5->{$digest} ) {
49 $report->{file}->{$file}->{duplicates}++;
51 print $out_fh $rec . $_;
52 $report->{file}->{$file}->{records}++;
53 $report->{total_records}++;
68 warn "# $path ", -s $path, dump $report;