Created
September 24, 2013 16:37
-
-
Save vzarytovskii/6687485 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!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