untested. idea was to extend functionality to as many words as passed, and get a return that was a bit more informative than just the number of shared characters. is the idea ok, code aside?
$class = ‘[a-z]’;
@commonChars = compareChars( $class );
sub compareChars {
$regex = shift;
$requiredCount = @ARGV;
for ( $i=0; $i<=$#ARGV; $i++ ) {
while ( $ARGV[$i] =~ m/($regex)/gi ) {
$found{$1} = $i + 1;
}
}
while ( ( $key, $value ) = each %found ) {
push @answer, $key if $value == $requiredCount;
}
return @answer;
}