Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Find common prefix from a list of strings

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found