in reply to Re^4: passing @ to sub and getting back hash
in thread passing @ to sub and getting back hash
My New Year's resolution is to remember (from Regexp Quote Like Operators):
If the /g option is not used, m// in list context returns a list consisting of the subexpressions matched by the parentheses in the pattern, i.e., ($1, $2, $3...). (Note that here $1 etc. are also set, and that this differs from Perl 4's behavior.) When there are no parentheses in the pattern, the return value is the list (1) for success. With or without parentheses, an empty list is returned upon failure.
My version simply does explicitly what jwkrahn's code does implicitly. So 'better' is a function of remembering the match operator's behavior in list context, which for some reason (probably to do with skull thickness) I seem to have trouble doing.
|
|---|