You should simply test for
if ( @a )
That will catch all cases:
- the sub returns undef -> false
- the sub returns an emtpy array ->false
- the sub returns a filled array ->true
The problem with your code is, that even an empty array is defined, so your comparison always returns true.