http://www.perlmonks.org?node_id=274133


in reply to Find common prefix from a list of strings

sub FindCommonPrefix { my $model= pop @_; my $len= length($model); for my $item ( @_ ) { my $dif= $model ^ substr($item,0,$len); $len= length( ( $dif =~ /^(\0+)/ )[0] ); substr( $model, $len )= ""; } return $model; }
                - tye