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

Re: Find common prefix from a list of strings

by antirice (Priest)
on Jul 15, 2003 at 00:42 UTC ( #274241=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub Prefix {
      my ($m,$n) = (sort @_)[0,-1];
    ...
      my $len= length( ( $dif =~ /^(\0*)/ )[0] );
      substr( $m, 0,$len );
    }
    
  2. or download this
    use Benchmark;
    @files = qw(model4run1 model2run1 model4run2);
    ...
    Benchmark: timing 100000 iterations of Jenda, antirice...
         Jenda:  1 wallclock secs ( 0.82 usr +  0.00 sys =  0.82 CPU) @ 12
    +1904.76/s (n=100000)
      antirice:  1 wallclock secs ( 0.75 usr +  0.00 sys =  0.75 CPU) @ 13
    +3333.33/s (n=100000)
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-01-21 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?