in reply to comparing lines of data
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11108762 use warnings; $_ = <<''; 1 2 3 4 1 2 3 5 1 2 4 6 1 2 3 4 1 2 3 5 1 2 4 7 4 6 3 9 my (@match, @nomatch); while( /^(?=((?:.*\n){5})(.*\n))/gm ) { my ($five, @six) = ($1, sort split ' ', $2); my %found = map +($_ => 1), split ' ', $five; push @match, "@{[ grep $found{$_}, @six ]}\n"; push @nomatch, "@{[ grep !$found{$_}, @six ]}\n"; } print "match:\n", @match, "\nnomatch:\n", @nomatch;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparing lines of data
by Scotmonk (Sexton) on Nov 15, 2019 at 22:38 UTC | |
by AnomalousMonk (Archbishop) on Nov 16, 2019 at 01:51 UTC | |
by harangzsolt33 (Deacon) on Nov 16, 2019 at 01:03 UTC | |
by marto (Cardinal) on Nov 16, 2019 at 09:26 UTC |