9 ms·
> Even today, I'm not sure if a function that returns a list (not list ref) can be directly dereferenced into via [] notation. Unless it's changed very recentl
by aaronem 12y ago
> Even today, I'm not sure if a function that returns a list (not list ref) can be directly dereferenced into via [] notation.
Unless it's changed very recently, you cannot; you have to wrap it in an arrayref, e.g.
[returnsAList()]->[0]
- jondum_bau 12y agoall lists can be sliced with the [] notation. the above example would returnsAList, put it in a new array reference, then dereference it. probably not want you want. To get the first item from the sub with [] notation would be (returnsAList)[0] perl -e 'sub returnsAList { return 0..5 }; $v = (returnsAList)[3]; warn $v'