Search notes:

Perl module Sort::Merge

#!/usr/bin/perl
use warnings;
use strict;
use feature 'say';
use Sort::Merge;

open (my $fh1, '<', 'input_1') or die;
open (my $fh2, '<', 'input_2') or die;


Sort::Merge::sort_coderefs(
    [  sub { read_line($fh1) },
       sub { read_line($fh2) }
    ], sub { 
        my $x   = shift;
        my $key = $x->[1];
        my $val = $x->[2];
        say "$key $val";
    }
);

sub read_line {
  my $fh = shift;
  my $line = <$fh>;
  return () unless $line;

  return split ' ', $line;
}
Github repository PerlModules, path: /Sort/Merge/script.pl
Input files:
1 one
3 three
4 four
6 eight
8 eight
Github repository PerlModules, path: /Sort/Merge/input_1
2 zwei
3 drei
7 sieben
8 acht
9 neun
Github repository PerlModules, path: /Sort/Merge/input_2
Output:
1 one
2 zwei
3 three
3 drei
4 four
6 eight
7 sieben
8 eight
8 acht
9 neun

See also

Algorithms: merge
Perl modules.

Index