Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Find common prefix from a list of strings

by yosefm (Friar)
on Jul 14, 2003 at 20:15 UTC ( #274142=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://274142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2020-01-21 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?