On May 21, 11:32pm, Roderick Ford wrote:
> Does anybody know if, in perl, I 'push' an empty list or array to an
> array, does the array still grow by one? Or should I handle the
> indexing manually in those cases where it is empty. Sometimes my array
> that I am pushing is empty, but I still want the array to grow by one.
If you do...
@foo = ();
@bar = ();
push @bar, @foo;
...you'll find that @bar is empty afterward.
If you want to push a value on even when @foo is empty, you could do
it like this:
push @bar, (@foo ? @foo : undef);
Kevin