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