{ my @FIELDS = qw( foo bar baz ); sub set_params { use CGI qw(:standard); map { $_ => param($_) || '' } @FIELDS; } } # Other subroutines here { my %params = set_params(); # Call other subroutines here } #### { my @FIELDS = qw( foo bar baz ); sub new { my $class = shift; my $in = shift || { }; # Passed in a hashref my %self = map { $_ => $in->{$_} || '' } @FIELDS; bless \%self, $class; } }