my $key_fields = [ qw( trade_ref sec_code lot of other fields ) ]; my $copy_fields = [ qw( item_period other fields) ]; my $audit = {}; @{$audit}{@$key_fields} = @{$item}{@$key_fields}; # $item is a hashref with some but maybe not all of the # above fields defined $audit->{$_} = $item->{$_} || '' for @$copy_fields;