sub build_list { my ($arg1, arg2, ...) = @_; my @list = (); ... if (something) { return @list; } else { return (); } } #### sub build_list { ... my @list = (); if ( something ) { push @list, $whatever, ...; } return @list; # list could still be empty at this point }