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


in reply to Find common prefix from a list of strings

Not exactly golfed to death, but:
@files = qw(model4run1 model2run1 model4run2 model1run1); $x++,"$files[0] "=~/(.{$x})/ while (grep/^$1/,@files)==@files; chop($_=$1); print;