Skip to content

Instantly share code, notes, and snippets.

@boopsie
boopsie / lcp.pl
Created August 9, 2012 23:50
Perl Longest Common Prefix
# returns longest common prefix of a list of strings
sub lcp
{
my $match = shift;
substr($match, (($match ^ $_) =~ /^\0*/, $+[0])) = '' for @_;
$match;
}