Thread Umgekehrtes grep gesucht
(7 answers)
Opened by TheUser at 2009-04-13 17:05
Hier mal eine Alternative:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 use strict; use warnings; use Data::Dumper; my @stuff1 = qw/a b c d/; my @stuff2 = qw/a d/; my %seen; my @stuff1_only; my $element; foreach $element(@stuff2) { $seen{$element} = 1; } foreach $element (@stuff1) { unless ($seen{$element}) { push (@stuff1_only, $element); } } print Dumper \@stuff1_only; |