in reply to Difference between this array assignment and push
I'm betting the first one is slightly faster (fewer Perl ops). The second uses less overhead memory (only one match on the stack at a time). These factors are probably negligible.
Perl is very efficient at expanding (and shrinking) arrays at either end, so there's no advantage to knowing the size of the array before the assignment. If Perl wasn't so good at this, the second one would be much slower due to multiple reallocations of the array.
|
|---|