in reply to Add values to subroutine inside of a loop.
You seem to want to expand all of the hash refs. in the $added array ref. into an anonymous hash, but the keys are the same in all the $added hash referents. So, e.g., each 'link' key's value will simply overwrite the preceding value until the last such key, and likewise for all the 'name' keys.
What do you really want to do here?c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $added = [ { link => '/var/www/docs', name => 'mydocs', }, { link => '/var/www/read', name => 'letters', } ]; ;; my @keys = qw(link name); ;; my $hashref = { map { my $k = $_; map { $k => $_->{$k} } @$added } @keys, }; ;; dd $hashref; " { "link" => "/var/www/read", name => "letters" }
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Add values to subroutine inside of a loop.
by Anonymous Monk on Jul 02, 2018 at 18:28 UTC | |
by haukex (Archbishop) on Jul 02, 2018 at 18:41 UTC |