Reputation: 365
I was looking at some code which looks like the following --
foreach my $name (@places{$${newones}}) {
my $item = $$name{item};
my $temp = $$name{temp};
}
I wanted to know which other fields are there like $$name{temp}, $$name{item}, how can I print all of that?
Upvotes: 0
Views: 235
Reputation: 40758
To print the other keys and values of the hashref $name
you can do something like:
use feature qw(say);
use strict;
use warnings;
my $place = "place";
my $newones = \$place;
my %names = (item => "item_value", temp => "temp_value");
my %places = (place => \%names);
for my $name (@places{$${newones}}) {
for my $key (keys %$name) {
say "$key = $$name{$key}";
}
}
Output:
temp = temp_value
item = item_value
Upvotes: 1