Perl Monk, Perl Meditation | |
PerlMonks |
Re: Perl Idioms Explained - ${\$obj->method} and @{[sort @list]}by Abigail-II (Bishop) |
on Aug 21, 2003 at 15:58 UTC ( [id://285505]=note: print w/replies, xml ) | Need Help?? |
One must be careful with the ${\foo} because if foo returns something that isn't a simple scalar value then you might get unexpected results. To be more precise, the \ operator gives its argument list context, which may surprise many people (it did me). The other interpolation construct @{[ ]} also provides list context. This is something to be aware of, and use of scalar will be appropriate in some cases, including in ${\scalar foo}. Abigail
In Section
Meditations
|
|