Solution #5 - Count and Replace
sub count_and_replace
{
my $s = shift;
my $count = (my @a = ($s =~ /\./g));
$s =~ s/\./(--$count)?"":"."/ge;
return $s;
}
| TATMWTDI | There are too many ways to do it | #10 |
sub count_and_replace
{
my $s = shift;
my $count = (my @a = ($s =~ /\./g));
$s =~ s/\./(--$count)?"":"."/ge;
return $s;
}
| Copyright © 2005 Shlomi Fish |