Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Find common prefix from a list of strings

by Willard B. Trophy (Hermit)
on Jul 14, 2003 at 22:06 UTC ( #274204=note: print w/replies, xml ) Need Help??


in reply to Find common prefix from a list of strings

Though the problem's well and answered by the time I got to this, it did strike me that Text::Abbrev would sort of work to solve this.

Indeed, if you do:

%abbrevs = abbrev(@files); @possibles = sort { length($a) <=> length($b) } ( keys(%abbrevs) );

the first entry in @possibles is most of the way to the solution. I don't have time to look into this further, alas, but it might be another way to do it.

--
bowling trophy thieves, die!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2020-01-28 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?