in reply to Find common prefix from a list of strings

why not try a regexp?
@files = qw(model4run1 model2run1 model4run2 model); $reg = ' \\1[^ ]*' x $#files; "@files" =~ /^([^ ]*)[^ ]*$reg$/; print $1;

Of course, all the usual catches apply, like having spaces, return characters, etc. in your filenames.

No idea how slow this is..

Jasper