Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Find common prefix from a list of strings

by yosefm (Friar)
on Jul 14, 2003 at 20:15 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://274142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-24 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found