laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Perl "flattens" arrays and hashes passed as parameters to a sub into a list of scalar values (see the perlsub Description section, paragraph two. In your case it is not possible for the sub to tell the difference between a call with no parameters and a call containing one or more empty array and empty hash parameters. Perhaps a solution is to use a "sayArray" sub that does the multi-line thing and use Perl's "say" in other cases? That has the advantage that it clearly signals to the user that something special is happening in the array case. Perl's built in "say" doesn't need any magic for handling a "no argument" case. It just does what print does (in that case it prints nothing) then prints a newline, which is what it always does.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
In reply to Re: Spotting an empty array as argument
by GrandFather
|
|