my %seen = (); # use hash for counting elements
my @doubles = grep {
# if value not in seen, return 0 and add it
# to %seen with start value of 1
$seen{$_}++
} @array1;
foreach my $element ( @doubles ) {
print "$element\n";
} # foreach @doubles
undef %seen;
disadvantage: if you have three or more values, they will be printed more than once, so the following solution might be more precise:
my %seen = ();
$seen{$_}++ for @array1;
for my $value ( keys %seen ) {
print "$value\n" if $seen{$value} > 1;
} # for %seen
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"