use strict; use warnings; my $arrayref = getArrayref(); # this sometimes returned undef # Manually vivify it. $arrayref ||= []; if (@$arrayref) { ... }