in reply to Problem with Hash when Using Strict

There are a few problems here. You are using %hash for 2 different things: a hash with key=site, value=ftp.siebel.com; a hashref with key={ftp.siebel.com}{ip_now} = 64.181.143.36 and {ip_new} = something other ip address.

Your loop structure complains that the hashref is missing when the key=site. Adding the following would get rid of the error, but only by filling in the void after line 39 above:

$hash{site} = $ftp_siebel_dns; $hash{site}{ip_now} = "x"; $hash{site}{ip_new} = "y";

A better way would be to change the structure to:

%HoH = ( $ftp_siebel_dns => { ip_now => $ftp_siebel_ip, ip_new => $ftp_siebel, }, );

That looks about the same, but you would not have any key called site.

Replies are listed 'Best First'.
Re^2: Problem with Hash when Using Strict
by Eimi Metamorphoumai (Deacon) on Sep 17, 2004 at 20:15 UTC
    $hash{site} = $ftp_siebel_dns; $hash{site}{ip_now} = "x"; $hash{site}{ip_new} = "y";
    That won't work for the same reason the OP's code doesn't work--you're making $hash{site} both a string and a hashref. The other suggestion is good, though.