my @names = qw(name age location); # add do this list whenever
# make a hash reference and populate it
@$fields{@names} = ( ... list of corresponding values ...);
####
# a normal hash assignment - scalar context
$field{'name'} = 'Richard';
# a normal hash assignment - list context
@field{qw(name age)} = qw(Richard 24);
####
use strict;
my @names = qw(name age location); # add do this list whenever
# make a hash reference and populate it
my $fields = {}; # declare $fields being a hash reference
@$fields{@names} = ( ... list of corresponding values ...);
####
$mech->submit_form(
form_name => $search_form,
fields => $fields,
}
);