Avoid length of undefined values

Old perls (5.10.1) warn on undef passed to length