sub ikegami1 { my ($ref, @wordsCopy) = @words; while, ($ref =~ /(.)/g) { my $letter = $1; my $pos = $-[0]; for ( @wordsCopy ) { if ( substr( $_, $pos, 1 ) ne $letter ) { substr( $ref, $pos, 1, '-' ); last; } } } return $ref; } sub ikegami2 { my ($ref, @wordsCopy) = @words; for my $pos (0..length($ref)) { my $letter = substr( $ref, $pos, 1 ); for ( @wordsCopy ) { if ( substr( $_, $pos, 1 ) ne $letter ) { substr( $ref, $pos, 1, '-' ); last; } } } return $rv; } sub ikegami3 { my @wordsCopy; push @wordsCopy, [ /./g ] for @words; my $ref = pop(@wordsCopy); for my $pos (0..$#$ref) { my $letter = $ref->[$pos]; for ( @wordsCopy ) { if ( $_->[$pos] ne $letter ) { $ref->[$pos] = '-'; last; } } } return join '', @$ref; }