my @a=(0..12); #ursprungsmenge (0 bis 12)
my $i=0;
my @b=(2,4,6,9,11); #mag ich nicht haben
while ($#b >= 0) {
splice(@a,$b[0]-$i,1);
shift(@b);
$i++;}print @a; #@a enthält ursprungsmene ohne @b
splice ist teuer.
Arbeite mit einem hash und einer Array kopie
~~~perl
my @in = (0 .. 100);
my @no = (42, 4711);
my %no = map{$_ => 1;} @no;
my @ret=();
foreach(@in){
exists $no{$_} or push @ret, $_;
}
mfg Beat
--
><o(((°> ><o(((°>
<°)))o>< ><o(((°>o
Der Valigator leibt diese Fische
><o(((°> ><o(((°>
<°)))o>< ><o(((°>o
Der Valigator leibt diese Fische