in reply to String matching problem

This captures the last character, also asserting it is a digit.
my ($last_char_digit) = ($string =~ /(\d)\z/);
If your "always" isn't true, then the value will be undef.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.