Anonymous Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dvijayan
    New Member
    • Mar 2008
    • 3

    Anonymous Array

    Hi ,

    How to get the length of Anonymous array.
    In my code sometimes the Anonymous array is becoming empty want to go a head only if the array is not empty...how to do??

    Thanks
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    You don't really need to check the length if all you want to know is if the array has something in it or not, you can just use "if" with "!" to see if it does:

    Code:
    @array = ();
    $array_ref = \@array;
    if (! @{$array_ref}) {
       print "Empty";
    };
    Note you do have to dereference the array reference to check its status (empty or not).

    Comment

    Working...