I’m looking at the following code snippet:
my @ret = <someMethod> return (undef) if( $DB_ERROR ); return (undef) unless ($#ret >= 0);
Does $# just give you a count of elements in a array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$#arraynamegives you the index of the last element, so if array@rethas 2 elements then$#retis 1.And, as noted by Barry Brown, an empty array gives -1.
To get the length you can use the array in scalar context: