Abbreviations, automatic: Difference between revisions
Content deleted Content added
Added Go |
SqrtNegInf (talk | contribs) Added Perl example |
||
Line 834:
2 Killachau Atichau Quoyllurchau Illapachau Chaskachau Kuychichau Intichau
</pre>
=={{header|Perl}}==
Output is the same as for Perl 6.
{{trans|Perl 6}}
<lang perl>use utf8;
binmode STDOUT, ":utf8";
sub auto_abbreviate {
my($string) = @_;
my @words = split ' ', $string;
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;
}
return '∞';
}
open $fh, '<:encoding(UTF-8)', 'DoWAKA.txt';
while ($_ = <$fh>) {
print "$.) " . auto_abbreviate($_) . ' ' . $_;
}</lang>
=={{header|Perl 6}}==
|