sub _select_fields { my $self = shift; my %rev_types = ( both => sub { # some difficult logic }, total => sub { [qw/foo bar/] }, ); my $rev_type = $self->request->param('rev_type'); $rev_type = 'both' unless exists $rev_types{$rev_type}; return @{$rev_types{$rev_type}->()}; }