Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Find common prefix from a list of strings

by Jasper (Chaplain)
on Jul 15, 2003 at 10:10 UTC ( #274338=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2020-01-20 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?