Solution #6 - Eliminate the Last
sub elim_last { my $s = shift; my $non_occur = "\x{1}" . ("\0" x length($s)) . "\x{1}"; $s =~ s/\.([^\.]*)$/$non_occur$1/; $s =~ tr/.//d; $s =~ s!$non_occur!.!; return $s; }
TATMWTDI | There are too many ways to do it | #11 |
sub elim_last { my $s = shift; my $non_occur = "\x{1}" . ("\0" x length($s)) . "\x{1}"; $s =~ s/\.([^\.]*)$/$non_occur$1/; $s =~ tr/.//d; $s =~ s!$non_occur!.!; return $s; }
Copyright © 2005 Shlomi Fish |