TATMWTDIThere are too many ways to do it#6

Solution #1 - Via Split

sub via_split
{
    my $s = shift;
    my @components = split(/\./, $s, -1);
    if (@components == 1)
    {
        return $s;
    }
    my $last = pop(@components);
    return join("", @components) . "." . $last;
}
Copyright © 2005 Shlomi Fish