Skip to content

Instantly share code, notes, and snippets.

@vzarytovskii
Created September 24, 2013 16:37
Show Gist options
  • Save vzarytovskii/6687485 to your computer and use it in GitHub Desktop.
Save vzarytovskii/6687485 to your computer and use it in GitHub Desktop.
#!perl
use warnings;
use strict;
my $x = [1,2,3];
my $y = [2,3,4];
my $t = [3,4,5];
sub substract {
my @arrays = @_;
my %h = ();
foreach my $array(@arrays) {
map {
$h{$_}+=1;
} @$array;
};
my @result = grep { $h{$_} == 1 } keys %h;
return wantarray ? @result : \@result;
}
use Data::Dumper;
my $xx = substract($x,$y,$t);
warn Dumper($xx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment