in reply to Functions that return nothing, nada, failure...
This to me _reads_ clearly that an empty list is being returned by a function that operates on lists.sub build_list { my ($arg1, arg2, ...) = @_; my @list = (); ... if (something) { return @list; } else { return (); } }
Well, if that sub is actually set up so that @list only gets things pushed into it when "something" is true, then you don't need the two different return conditions -- that is:
and when @list is empty, that return statement is exactly equivalent to "return ();" -- to me, this reads even more clearly.sub build_list { ... my @list = (); if ( something ) { push @list, $whatever, ...; } return @list; # list could still be empty at this point }
|
|---|