Created
July 19, 2019 03:51
-
-
Save gugod/403e1bab96e0eda7080d650abbbac7ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.18; | |
use List::MoreUtils qw<firstidx>; | |
sub pairwise_eq(\@\@) { | |
my ($a1, $a2) = @_; | |
return @$a1 == @$a2 && (-1 == firstidx { $a1->[$_] ne $a2->[$_] } 0..$#$a1); | |
} | |
my @a1 = qw(foo bar baz); | |
my @a2 = qw(foo bar baz); | |
my @a3 = qw(foo cook bar baz); | |
say "a1 vs a2 => " . (pairwise_eq(@a1, @a2) ? "All euqal" : "At least one difference"); | |
say "a1 vs a3 => " . (pairwise_eq(@a1, @a3) ? "All equal" : "At least one difference"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment