in reply to Extract last two digits from numbers

If you know that your numbers are numbers, then there's no need to use a regex, just math.

my $number = '0234'; $number %= 100; print $number; 34

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!

Replies are listed 'Best First'.
Re: Extract last two digits from numbers
by Abigail-II (Bishop) on Jan 06, 2004 at 11:19 UTC
    my $number = '3204'; $number %= 100; print $number; 4

    Abigail

      Good point. I guess it depends on whether the OP wants two characters or the numeric value of the last two digits.

      Without clarification, my interpretation is probably the least likely given context.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Hooray!