Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature qw(say);
- open my $csv1, $ARGV[0] or die;
- open my $csv2, $ARGV[1] or die;
- my $ret = {};
- while (<$csv1>) {
- chomp;
- my @d = split /\s*,\s*/;
- $ret->{$d[0]} = [$d[1]];
- }
- while (<$csv2>) {
- chomp;
- my @d = split /\s*,\s*/;
- if ($ret->{$d[0]}) {
- push $ret->{$d[0]}, $d[1];
- } else {
- $ret->{$d[0]} = [$d[1]];
- }
- }
- close $csv1;
- close $csv2;
- foreach my $r (sort keys %$ret) {
- next unless @{$ret->{$r}} == 2;
- say "$r," . join ',', @{$ret->{$r}};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement