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

Re^3: Find common prefix from a list of strings (trailing \)

by tye (Sage)
on Nov 10, 2003 at 00:09 UTC ( #305755=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub maxprefix {
      my $p = quotemeta shift;
      for (@_) { chop $p until /^$p/ }
      return $p;
    }
    
  2. or download this
    sub maxprefix {
        my $p = shift(@_);
        for(@_) { chop $p  until /^\Q$p/ }
        return $p;
    }
    
  3. or download this
    sub maxprefix {
      my $s = reverse shift;
    ...
      chop $p;
      return $p;
    }
    
  4. or download this
    print maxprefix("testing","terse","tester","time"),$/;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2020-01-24 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?