filter script

master
Vincent Schweiger 2024-01-28 15:19:12 +01:00
commit 9e2e13f32c
Signed by: vincent
GPG Key ID: F83B0F0E383CC23F
1 changed files with 44 additions and 0 deletions

44
filter.pl Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/perl
use strict; use warnings;
my %seen = ();
for (;;) {
my $input = <STDIN>;
last if not defined $input;
chomp $input;
my @l = $input =~ /([0-9]+\/[0-9]+\/[0-9]+)/mg;
foreach my $item (@l) {
$seen{$item}++;
}
}
my @uniq = sort gw_comp keys %seen;
if (@uniq) {
print "@uniq\n";
}
sub gw_comp{
# extract $1/$2/$3 for both GAs
$a =~ /([0-9]+)\/([0-9]+)\/([0-9]+)/;
my $a1 = $1;
my $a2 = $2;
my $a3 = $3;
$b =~ /([0-9]+)\/([0-9]+)\/([0-9]+)/;
my $b1 = $1;
my $b2 = $2;
my $b3 = $3;
if ($a1 < $b1) {
return -1;
} elsif ($a1 == $b1) {
if ($a2 < $b2) {
return -1;
}
elsif($a2 == $b2) {
return $a3 <=> $b3;
}
}
return 1;
}