SPUG:array arg to push
Damian Conway
damian at conway.org
Fri Mar 21 23:54:22 CST 2003
Michael R. Wolf wrote:
> Has anyone used an expression as the first argument to push? I know
> that there's something special about the prototype of the builtins so
> that they can take an array as the first argument without expanding
> it, but had hoped that I could have an expression as the first
> argument.
The \@ prototype of C<push> requires that the corresponding argument literally
begin with a @.
> This doesn't work. Ideas?
>
> my ($min, $max) = (1, 10);
> foreach ($min..$max) {
> push(($_%2 ? @odd : @even), $_);
push @{ $_%2 ? \@odd : \@even}, $_;
Damian
More information about the spug-list
mailing list