my %ret = map $_->{key} =~ /^a\d/ ? ( $_->{ key } => $_->{ value } ) : (), @$data1;