Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Find common prefix from a list of strings

by artist (Parson)
on Jul 14, 2003 at 19:48 UTC ( #274131=note: print w/replies, xml ) Need Help??


in reply to Find common prefix from a list of strings

An alternative:
@files = qw(model4run1 modexl2run1 model4run2 model1run1); my @array = split //,shift @files; my @prefix; foreach (@files) { @prefix = (); while ($c = shift @array) { next unless /^$c/; s/^$c//; push @prefix,$c; } @array = @prefix; } print join ""=>@prefix,"\n";

Log In?
Username:
Password:

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

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