yeah, the while length $_ will do it; see modified code
In reply to Re^2: How to transpose lines faster? by pryrt in thread How to transpose lines faster? by rsFalse