in reply to Re^4: number array with space
in thread number array with space

See looks_like_number in Scalar::Util like thus:

use Scalar::Util qw(looks_like_number); for(qw(1 perl 25 monks)){ looks_like_number $_ ? print $_," is a Number",$/ : print $_," is not a Number",$/; }
Update:
Awooooshhhh! davido, beat me to it.....

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^6: number array with space
by davido (Cardinal) on Jun 20, 2013 at 07:28 UTC

    Yeah, but I left out the example, which you thoughtfully provided. ...or I left it as an exercise for the reader to figure out. ;)


    Dave

Re^6: number array with space
by MynameisAchint (Novice) on Jun 20, 2013 at 07:59 UTC
    hey

    what i want to do is that check whether the array cell has a number or not , if yes execute my block of code else not i.e.

    if( $array[$i] == number ) { my block of code ; }
      Simply go for regex then:
      if ($array[$i] =~ /\d+/){ <your code> }
        if ($array[$i] =~ /\d+/){ <your code> }

        But that matches non-numbers:

        >perl -wMstrict -le "print 'this is a number?!?' if 'x9x' =~ /\d+/; " this is a number?!?

        Better to use  Scalar::Util::looks_like_number() (see this), which correctly identifies numbers like  '1.2' '1.2e3' '0e0', or if only decimal digits are acceptable, use the  /^\d+$/ regex (see this).