Skip to content

Instantly share code, notes, and snippets.

@ology
Last active December 14, 2022 18:26
Show Gist options
  • Save ology/02c06ca481bb53bb28a3e4e27d18b7bb to your computer and use it in GitHub Desktop.
Save ology/02c06ca481bb53bb28a3e4e27d18b7bb to your computer and use it in GitHub Desktop.
Process F1 & F2 into F3 text files
#!usr/bin/env perl
use strict;
use warnings;
my $F1 = 'F1.txt';
my $F2 = 'F2.txt';
my $F3 = 'F3.txt';
my %f2_map;
open(my $fh2, '<', $F2) or die "Can't read $F2: $!";
while (my $line = readline($fh2)) {
my ($key, $val) = split /[:-]/, $line;
$f2_map{"$key $val"}++;
}
close $fh2;
#use Data::Dumper::Compact qw(ddc);
#warn __PACKAGE__,' L',__LINE__,' ',ddc(\%f2_map);
open(my $fh3, '>', $F3) or die "Can't write $F3: $!";
open(my $fh1, '<', $F1) or die "Can't read $F1: $!";
while (my $line = readline($fh1)) {
my ($key, $val) = split /\s+/, $line;
#warn __PACKAGE__,' L',__LINE__,' ',,"$key, $val\n";
next if exists $f2_map{"$key $val"};
print $fh3 $line;
}
close $fh1;
close $fh3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment