Consider this code:
@tmp = split(/\s+/, "apple banana cherry");
$aref = \@tmp;
Besides being inelegant, the above code is fragile. Say I follow it with this line:
@tmp = split(/\s+/, "dumpling eclair fudge");
Now $$aref[1] is "eclair" instead of "banana".
How can I avoid the use of the temp variable?
Conceptually, I'm thinking of something like
$aref = \@{split(/\s+/, "apple banana cherry")};
splitreturns a list of scalars, just like any sub.