in reply to Matching or masking specific characters in an array of strings
#! /usr/bin/perl/ -w use strict; my @strings = qw ( cooling rooting hooting looking doormat ); our @common_letters; my $reference = shift @strings; () = $reference =~ /(.)(?{ my $letter = $1; my $position = $-[0]; my $bolean = 1; for ( @strings ) { if ( substr( $_, $position, 1 ) ne $letter ) { $bolean = 0; last } } $common_letters[ $position ] = $letter if ( $bolean ); + })/gx; print ( $common_letters[ $_ ] || "-" ) for ( 0 .. length $reference );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching or masking specific characters in an array of strings
by johngg (Canon) on Dec 20, 2008 at 00:21 UTC | |
by pat_mc (Pilgrim) on Dec 25, 2008 at 22:13 UTC |