in reply to Find common prefix from a list of strings

Here is a bad solution just for variety.
my $sep = chr(033); my $str = join $sep, @files; if ($str =~ /^([^$sep]*)[^$sep]*($sep\1[^$sep]*)*\z/s) { print "Common substring: '$1'\n"; } else { die "Pattern unexpectedly failed to match?"; }
Of course it assumes that chr(033) does not appear in the strings...