in reply to Checking Arrays

Use $#search to find the size of the array

Replies are listed 'Best First'.
Re: Re: Checking Arrays
by grep (Monsignor) on Aug 19, 2002 at 03:55 UTC
    Use $#search to find the size of the array

    No, it will not return the number of elements in an array!!!

    $#search will tell you the last index position.

    So a one element array 'my @arr = qw/ one /;'
    $#arr will return 0 which is false, not what the poster wanted



    grep
    Mynd you, mønk bites Kan be pretti nasti...
Re: Re: Checking Arrays
by vek (Prior) on Aug 19, 2002 at 13:39 UTC
    Use $#search to find the size of the array.

    Slightly OT seeing as that's not what the poster was asking. Anyhoo, that's not how you find the size of an array. You'd want to do something like this:
    my $count = @search;
    Update: Useless use of scalar alert, cheers Abigail-II!

    -- vek --
      Useless use of scalar alert!
      my $count = @search;
      will do fine.

      Abigail