Most of the time I wouldn't be tempted to write functions that operate on $_ if given no arguments. trim($_) is just not a big hardship compared to trim() (although I do use implicit $_ in some cases, I usually don't with chomp(), for example).
If I had a function that used $_ when given no arguments, then I'd likely not support taking a list of arguments (because of the ambiguity you noticed). Though, if you aren't likely to run into a relatively old version of Perl, then there is a somewhat ugly way around the ambiguity problem that I'm reluctant to mention because somebody would probably use it:
- tye
In reply to Re: Is silent use of $_ for empty argument lists reasonable for "shortcut" functions? (E2CUTE)
by tye
in thread Is silent use of $_ for empty argument lists reasonable for "shortcut" functions?
by Wyrdweaver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |