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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759407980, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/Sort/Merge/index(96): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78