use strict; use warnings; my $arrayref = getArrayref(); # this sometimes returned undef if ($arrayref && @$arrayref) { ... }