use strict; use warnings; use Data::Dumper; sub bin2num($) { my $v = 0; foreach my $b (split(//,shift)) { $v <<= 1; $v += $b; } $v; } sub prepare_line($) { my $line = shift; chomp $line; my $l = $line; $l =~ s/^row(\d+)\s+//; $l =~ s/\s+//g; # Leerzeichen entfernen; my $mask = $l; $mask =~ tr/-01/011/; $mask = bin2num($mask); # Ziffer => bit gesetzt my $pattern = $l; $pattern =~ tr/-01/001/; $pattern = bin2num($pattern); # '1' => bit gesetzt return { line => $line, mask => $mask,pattern => $pattern}; } my @all = map {prepare_line($_)} (); foreach my $target (@all) { print "\nTarget:\t\t",$target->{line},"\n"; foreach my $comp (@all) { next if $target->{line} eq $comp->{line}; # gleiche Zeile # numerischer Vergleich der in $comp gesetzten Ziffern, erst '0' dann '1' if (($comp->{mask} & $target->{mask} & ~$target->{pattern}) == ($comp->{mask} & ~$comp->{pattern}) and ($comp->{mask} & $target->{pattern}) == ($comp->{mask} & $comp->{pattern})) { print "Subset:\t\t",$comp->{line},"\n"; } } }