J
J Krugman
I would like to write something like
push &test($_) ? @sheep : @goats, $_ for @bleats;
but I get the error
Type of arg 1 to push must be array (not null operation)
Of course, I can break down and roll out something like
for ( @bleats ) {
if ( &test($_) ) {
push @sheep, $_
}
else {
push @goats, $_
}
}
....but, I'm curious, is there a way I can coax push into accepting
the one-line construct?
Thanks,
-Jill
push &test($_) ? @sheep : @goats, $_ for @bleats;
but I get the error
Type of arg 1 to push must be array (not null operation)
Of course, I can break down and roll out something like
for ( @bleats ) {
if ( &test($_) ) {
push @sheep, $_
}
else {
push @goats, $_
}
}
....but, I'm curious, is there a way I can coax push into accepting
the one-line construct?
Thanks,
-Jill