in reply to Find common prefix from a list of strings
@files = qw(model1bbb model2ccc model3i moduuu); PREF: for my $i (0..length($files[0])-1) { my $substr = substr($files[0], 0, $i+1); (/^$substr/ or ((print 'Pref', substr($files[0], 0, $i)), last PREF)) +for (@files[1..$#files]); }
Hope this helps.
Update: some people preceded me while I tested this...
In Section
Seekers of Perl Wisdom