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

(works only in a fairly recent version of Perl):
of course yes! in Perl 5.12 or better !!!. Nice one...

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^4: number array with space
by MynameisAchint (Novice) on Jun 20, 2013 at 06:51 UTC
    Hey

    one more question that how to check whether the element in an array is a number or not . is there any function in perl

      See Scalar::Util, and its function "looks_like_number". The module is core, meaning it ships with Perl.


      Dave

      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

        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

        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 ; }