[EMAIL PROTECTED] wrote: > > How do I extract the last digit of a number? example I only want the digit 9 from the number 19. > > my $number = 19;
There are a few ways. my $lastdigit = substr $number, -1; gives you the last character in the string my $lastdigit = $number % 10; gives you the remainder when $number is divided by 10 my ($lastdigit) = $number =~ /.*([0-9])/; gives you the last decimal digit (even if there are non-decimals after it). HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/