knx-groupfinder/filter.pl

45 lines
714 B
Perl
Raw Normal View History

2024-01-28 14:19:12 +00:00
#!/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;
}