From 9e2e13f32c347a5a7a0bcc9726e8e0292b95b77d Mon Sep 17 00:00:00 2001 From: Vincent Schweiger Date: Sun, 28 Jan 2024 15:19:12 +0100 Subject: [PATCH] filter script --- filter.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 filter.pl diff --git a/filter.pl b/filter.pl new file mode 100755 index 0000000..5f6c40e --- /dev/null +++ b/filter.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +use strict; use warnings; + +my %seen = (); + +for (;;) { + my $input = ; + 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; +}