my $last_digit = ''; if ($string =~ /(\d)$/) { $last_digit = $1; }