SPUG: parameterized push
Yitzchak Scott-Thoennes
sthoenna at efn.org
Sun Jan 11 04:04:25 CST 2004
On Thu, Jan 08, 2004 at 07:56:49PM -0800, "Michael R. Wolf" <MichaelRWolf at att.net> wrote:
> Is there an easier (i.e. more readable, and without resorting to
> references) way to pass an argument off to push?
Nope. $ perl -we'print prototype "CORE::push"'
\@@
push has a \@ as the first part of the prototype, and perlsub says:
Any backslashed prototype character represents an actual argument
that absolutely must start with that character. The value passed
as part of C<@_> will be a reference to the actual argument given
in the subroutine call, obtained by applying C<\> to that argument.
so only an array or array dereference (like you have) should work.
There is actually a bug that allows push CONST ? @a : @b, LIST to work,
but don't depend upon it, since it might get fixed.
More information about the spug-list
mailing list