my @s = qw/ 1234579 234789 4578 /; my $common = pop @s; $common =~ s/[^$_]//g for @s; print $common; # 47