in reply to Re: Find common prefix from a list of strings
in thread Find common prefix from a list of strings

Passes same tests as above, but with no capture or length call, might be slightly faster — but no benchmarking done. (I passed all arrays by reference in my testing.)

sub Prefix { my ($ar_strings, ) = @_; return '' unless @$ar_strings; my ($m, $n) = (sort @$ar_strings)[0,-1]; ($m ^ $n) =~ m{ \A \x00* }xms; return substr $m, 0, $+[0]; }