public
Created

Perl Longest Common Prefix

  • Download Gist
lcp.pl
Perl
1 2 3 4 5 6 7
# returns longest common prefix of a list of strings
sub lcp
{
my $match = shift;
substr($match, (($match ^ $_) =~ /^\0*/, $+[0])) = '' for @_;
$match;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.