Thread perlfaq4 - How do I compute the difference of: three arrays? (5 answers)
Opened by pktm at 2006-07-10 20:11

topeg
 2006-07-10 23:23
#68027 #68027
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Eine etwas unortodoxe Lösung:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use strict;
use warnings;

my @a1 = qw{ abc def 123 456 };
my @a2 = qw{ abc 123 789 };
my @a3 = qw{ def ghi 123 000 };

my @zusammen=sort(@a1,@a2,@a3);

my @neu=();

my $alt="";
while(@zusammen>0)
{
my $wert=shift(@zusammen);
push(@neu,$wert)if($wert eq $zusammen[0] and $alt ne $wert);
$alt=$wert;
}

print "#### VORGABE ####\n@a1\n@a2\n@a3\n";
print "#### ERGEBNIS ####\n@neu\n";
\n\n

<!--EDIT|topeg|1152560033-->

View full thread perlfaq4 - How do I compute the difference of: three arrays?