$history{ $+{ ticket } }{ $entry->{ action } } = { date => $words[0], time => $words[1], (\%+)->%{ grep exists( $+{ $_ } ), qw( order invoice shipment scheduled_date status ) } }; #### sub kv { my $h = shift; $h->%{ grep exists( $h->{ $_ } ), @_ } } kv( \%+, qw( ... ) ) #### $history{ $+{ ticket } }{ $entry->{ action } } = { date => $words[0], time => $words[1], (\%+)->%{qw( order invoice shipment scheduled_date status )} }; #### $history{ $+{ ticket } }{ $entry->{ action } } = { date => $words[0], time => $words[1], %+, };