in reply to <digits match>

You can also use substr with a negative offset:
my $last_digit = 5; if ($last_digit == substr $number, -1) { print "Matches!\n" }

Or, similarly, use rindex:

if (rindex($number, $last_digit) == length($number) - 1) { print "Matches!\n" }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ