in reply to Add new data to array
I'm guessing that you want to add the new values into the hashref that is $row, not to the arrayref that is $data?
If so then you can use slice assignment (untested):
my %new_row_data = (new_name => $name, new_ad1 => $ad1, new_City +=> $town, new_z_code => $zcode); @$row{keys %new_row_data} = values %new_row_data;
You could also loop over the keys of %new_row_data and add each key/value pair in turn if that's easier to follow. The slice is more efficient, though, so better for very large data sets.
my %new_row_data = (new_name => $name, new_ad1 => $ad1, new_City => +$town, new_z_code => $zcode); foreach my $key (keys %new_row_data) { $row->{$key} = $new_row_data{$key}; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Add new data to array
by Anonymous Monk on Mar 14, 2020 at 02:45 UTC | |
by AnomalousMonk (Archbishop) on Mar 14, 2020 at 05:50 UTC | |
by Anonymous Monk on Mar 14, 2020 at 22:44 UTC | |
by AnomalousMonk (Archbishop) on Mar 14, 2020 at 23:12 UTC | |
by Anonymous Monk on Mar 14, 2020 at 23:40 UTC | |
by Anonymous Monk on Mar 18, 2020 at 16:04 UTC |
In Section
Seekers of Perl Wisdom