use Sub::Context qw/arrayref first iterator custom/; sub foo : arrayref { # return wantarray ? @results : \@results; } sub bar : first { # return wantarray ? @results : $results[0]; } sub baz : iterator { # return wantarray ? @results : get_iterator(@results); } sub quux : custom { # user-defined return behavior? }