What is $object? It looks like it should be the loop variable in your foreach, but it isn't, here. In that case, you'd be pushing undef values, which might explain the blank lines.
Do you have use strict; at the top of your program?
Caution: Contents may have been coded under pressure.