Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Need explanatiin for subtle differenceby BillKSmith (Monsignor) |
on May 26, 2015 at 20:05 UTC ( [id://1127884]=note: print w/replies, xml ) | Need Help?? |
A good explanation is somewhat more subtle than other monks have indicated. First, we must realize that return inherits its context from the use of the function call. In both of your cases, it is scalar context. The difference between an actual array and a list in scalar context is documented in List Value Constructors. In your example, we should expect the array size from an actual array and the last element from a list. This is what you report.
Bill
In Section
Seekers of Perl Wisdom
|
|