Skip to content

Instantly share code, notes, and snippets.

@gugod
Created July 19, 2019 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gugod/403e1bab96e0eda7080d650abbbac7ee to your computer and use it in GitHub Desktop.
Save gugod/403e1bab96e0eda7080d650abbbac7ee to your computer and use it in GitHub Desktop.
#!/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