in reply to Problem with Hash when Using Strict

The previous two posts explain why you're getting the error. If you want to keep the 'site' key in the hash for whatever reason (even though it seems redundant), you can simply add another layer so it follows the HoH structure of the other data. That way all of the keys in %hash are hashrefs:

$hash{$ebiz_siebel_dns}{site} = $ebiz_siebel_dns; $hash{$ebiz_siebel_dns}{ip_now} = $ebiz_siebel_ip; $hash{$ebiz_siebel_dns}{ip_new} = $ebiz_siebel; for my $j ( keys(%hash) ){ print "site -> $j\n"; # $j eq $hash{$j}{site} print "$j -> $hash{$j}{ip_now}\n"; print "$j -> $hash{$j}{ip_new}\n"; }

It also seems that you are creating a lot of unnecessary variables (three for each site). You might want to consider restructuring this block something like this:

my %sites = ( 'messenger.hotmail.com' => { ipnow => '207.46.104.20', type => 'A' }, 'www.siebel.com' => { ipnow => '64.181.189.55', type => 'A' }, ); foreach my $dns ( keys %sites ) { $sites{$dns}{ipnew} = nslookup( host => $dns, type => $sites{$dns}{type} ); } foreach my $dns ( keys %sites ) { print "$dns\n"; print "$dns -> $sites{$dns}{ipnow}\n"; print "$dns -> $sites{$dns}{ipnew}\n"; }

This way, if you want to add (or remove) a site from the list, you simply edit the %sites hash and leave the rest of the code alone. It also keeps all of the nslookup calls together, and (IMO) it makes it easier to follow the code.

HTH