in reply to Re^3: Add new data to array
in thread Add new data to array
As you're making incremental improvements, here's another. Just a little Sunday morning exercise to get the mental juices flowing. :-)
Creating the four new_* key-value pairs and doing four // checks, always produces the same result: you only need to do that once. I kept your code up to and including my $add_in = ..., then added these two statements:
my $add_hashref = { map +('new_' . $_ => $add_in->{$_} // ''), grep $_ ne 'status', keys %$add_in }; %$_ = (%$_, %$add_hashref) for @$data;
The Dumper output is the same as yours; at least with a fairly thorough visual check, and bearing in mind that key-value pairs are unordered in a hash.
— Ken
|
|---|