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

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).

Replies are listed 'Best First'.
Re^9: number array with space
by gurpreetsingh13 (Scribe) on Jun 20, 2013 at 14:11 UTC
    sorry..
    if $array[$i] =~ /^\d+$/ { <block of code> }