SPUG: number

Michael R. Wolf MichaelRWolf at att.net
Thu Sep 21 13:35:14 PDT 2006

Of course, regular expressions could help..

if ( $number =~ /5$/ ) {

I forget that there are other "core" utilities (Damian calls them
"non-builtin built-ins" -- Scalar::Util, List::Util, List::MoreUtils).  

If you had to do work to figure out that it is a number, you could try this
(untested) code.

use Scalar::Util;

$is_numish = looks_like_number($string);
if ($is_numish && $string =~ /5$/) {

Michael R. Wolf
    All mammals learn by playing!
        MichaelRWolf at att.net 
From: spug-list-bounces+michaelrwolf=att.net at pm.org
[mailto:spug-list-bounces+michaelrwolf=att.net at pm.org] On Behalf Of luis
Sent: Tuesday, September 19, 2006 5:08 PM
To: spug-list at pm.org
Subject: SPUG: number inside of a number


I have a question, I need a variable where is holding a value (number) but I
need to check and verify the last digit. For example :
My $number=98765;

if ($number  last digit is 5)

I really appreciate you help. 


More information about the spug-list mailing list