if ((my $last_dot = rindex($string, '.')) > -1) { $result = substr( $string, 0, $last_dot + 1 ); }