Skip to content

Instantly share code, notes, and snippets.

@haodemon
Created August 16, 2017 17:20
Show Gist options
  • Save haodemon/5a69c80f51fac8da025bd9ad55b89c4c to your computer and use it in GitHub Desktop.
Save haodemon/5a69c80f51fac8da025bd9ad55b89c4c to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.016;
use strict;
use warnings;
sub array_minus(\@\@) {
my %e = map{ $_ => undef } @{$_[1]};
return grep( !exists($e{$_}), @{$_[0]} );
}
my @a = (1, 2);
my @b = (1, 2, 3);
say array_minus @b, @a;
say array_minus @a, @b;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment