my @services = qw(smtp http ssh); # list of services foreach (@services) { # Somehow get the details for the given service on # the given node. Here I'm assuming the existance of # a function that returns the required hash. my %details = get_details($node, $_); $node->{$_} = \%details; }