in reply to Spotting an empty array as argument

> , but if given a list, it should print each item with a newline.

maybe changing $, is just good enough for your task?

DB<223> $,="\n" DB<224> @a=(); @b=1..3; $_=666 DB<225> say @b 1 2 3 DB<226> say @a DB<227> say 666 DB<228>

But remember to use local, before changing global variables. :)

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

Replies are listed 'Best First'.
Re^2: Spotting an empty array as argument
by Chuma (Scribe) on Mar 26, 2021 at 14:25 UTC

    Ha, there's certainly an easy solution! It doesn't address the more general problem, but for this particular purpose it does the job. Thanks!

    The only thing slightly off here is that "saying" an empty list still makes a newline. You'd think getting n newlines for n outputs shouldn't be that hard, but anyway, close enough.