Luke Palmer wrote: > my @v = $( &func() ); > > Would provide scalar context. But then assign it to a list...
In the course of reading that I developed a concern about memory usage when trying to find the size of arrays. As I understand it the Perl 5 syntax for discovering the number of elements in a list will still work: $num = @massive; C<$num> becomes a reference to C<@massive>, but in a numeric context it will evaluate to the number of elements in that array. Suppose C<@massive> had 10_000 strings in it, and it goes out of scope but C<$num> stays in scope or its value is returned from a function. If C<$num> is just going to be used as a number then only the 10_000 needs to be stored in it, and the data in C<@massive> can be freed. But because C<$num> _might_ be used as an array ref, the data has to be kept around, which is wasteful. Does that matter? This example is fairly contrived, and anybody actually concerned about this can always use: $num = @massive.length; So perhaps this isn't a problem. Smylers