Cheers - L~R#!/usr/bin/perl -w use strict; my $number = 1234; my $last2; if ( $number =~ /^\d\d(\d\d)$/ ) { $last2 = $1; } print "$last2\n" if defined $last2;
Update: Regular expressions can be tricky as can be the notion of what constitutes a "number". You might also want to take a look at Mastering Regular Expressions and Scalar::Util's looks_like_number function for some more advanced stuff.
In reply to Re: Extract last two digits from numbers
by Limbic~Region
in thread Extract last two digits from numbers
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |