By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,835 Members | 2,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,835 IT Pros & Developers. It's quick & easy.

Anonymous Array

P: 3
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
Jul 10 '08 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
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:

Expand|Select|Wrap|Line Numbers
  1. @array = ();
  2. $array_ref = \@array;
  3. if (! @{$array_ref}) {
  4.    print "Empty";
  5. };
Note you do have to dereference the array reference to check its status (empty or not).
Jul 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.