in reply to Re: Spotting an empty array as argument
in thread Spotting an empty array as argument

good try :) But ...

DB<262> sub mysay (;+@) { print @_ } DB<263> mysay 1,2,3 123 DB<264> mysay 1..3 DB<265> mysay 1..3,4..6 456 DB<268>

It's enforcing scalar context on the first argument, and this is one of the unfortunate cases where an operator is changing it's meaning on context. :(

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Spotting an empty array as argument
by haukex (Archbishop) on Mar 26, 2021 at 22:41 UTC
    mysay 1..3

    Ah, a very good point, thanks!

    Chuma: This once again underlines the fact that, unfortunately (!), you're probably not going to get everything you want here. Perhaps it would also make sense to take a step back and explain what you want to use this function for? And if you think about it again, do you really need to default to $_? Or could you split this into two different functions? etc.