Abbreviations, automatic: Difference between revisions

m
→‎{{header|Perl}}: strict compliant
m (→‎{{header|Ruby}}: shaved off a line)
m (→‎{{header|Perl}}: strict compliant)
Line 1,729:
Output is the same as for Perl 6.
{{trans|Perl 6}}
<lang perl>use utf8strict;
use utf8;
binmode STDOUT, ":utf8";
 
Line 1,735 ⟶ 1,736:
my($string) = @_;
my @words = split ' ', $string;
my $max = 0;
return '' unless @words;
map { $max = length($_) if length($_) > $max } @words;
for $i (1..$max-1) {
my %seen;
return $i if @words == grep {!$seen{substr($_,0,$i)}++} @words;
2,392

edits