You invoke an anonymous sub with
->(). Your sub would be invoked with
$new_resolvers{"dns-extern"}[0]->($ip_address). The way you have your loop written, you'll have to tell the difference between a scalar and a sub though. You could rewrite the loop as:
print "getting new resolvers for dns server $dns_server\n";
for my $resolver ( @{$new_resolvers{$dns_server}} ) {
if (ref $resolver) {
print "$_\n" for $resolver->($ip);
} else {
print "$resolver\n\n";
}
}
print "\n";
I don't know where
$ip is supposed to come from, but that's the way you have your anonymous sub written.