[EMAIL PROTECTED] wrote:
Hi Frnds,

Hello,

If I have a number of 6 digits. How to get the last 2 digits. This
should be valid even when i have 2 digits as input.
i.e If input is 991041 then output shud be 41
     if input is  41 then output shud be 41

May be junk and simple question but ..i need this ..please do respond..

If you know it is going to be a valid integer then use modulus.

$ perl -le'
my $x = 991041;
my $y = $x % 100;
print $y;
'
41


If you don't really know what the number will be then:

$ perl -le'
my $x = 991041;
my ($y) = $x =~ /.*(\d\d)/;
print $y;
'
41



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to