in reply to Arrays and Scalar Parameters
Why return the count at all?
If the caller wants the count it can get it directly from the returned array.
#useful caller code goes here my(@arr,$count); @arr=myfunction(); $count=@arr; #more caller here
An array evaluated in a scalar context such as assigning to a scalar gives the number of elements in the array.
Update: seems that this is bad for some reason. The question could have been (or probably will be read by) new perl users and so knowing that you need not return the count of an array to access it is valuable? The original node said nothing about the array being multidimensional.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Arrays and Scalar Parameters
by descartes (Friar) on Aug 21, 2001 at 00:08 UTC |