if I disable strict, I get::!./temp site Can't use string ("ftp.siebel.com") as a HASH ref while "strict refs" in use at ./temp line 51. shell returned 255
I can't figure out why I'm getting an empty entry. Hashes always seem to drive me bonkers, but I think it's the best data structure to use in this scenario. I would appreciate any help.site Use of uninitialized value in concatenation (.) or string at ./temp line 51. site -> Use of uninitialized value in concatenation (.) or string at ./temp line 52. site -> ftp.siebel.com ftp.siebel.com -> 64.181.143.36 ftp.siebel.com -> 64.181.143.36 ebusiness.siebel.com ebusiness.siebel.com -> 64.181.189.50 ebusiness.siebel.com -> 64.181.189.50 www.siebel.com www.siebel.com -> 64.181.189.55 www.siebel.com -> 64.181.189.55 messenger.hotmail.com messenger.hotmail.com -> 207.46.104.20 messenger.hotmail.com -> 207.46.104.20
1 #!/usr/bin/perl -w 2 # 3 # lookup.pl - Check if these sites have changed their ip address 4 # 5 6 #use strict; 7 use Net::Nslookup; 8 use Mail::Sender; 9 10 my %hash; 11 12 # MSN Messenger 13 my $msndns = 'messenger.hotmail.com'; 14 my $msnip = '207.46.104.20'; 15 my $msn = nslookup(host => "$msndns", type => "A"); 16 17 $hash{site} = $msndns; 18 $hash{$msndns}{ip_now} = $msnip; 19 $hash{$msndns}{ip_new} = $msn; 20 21 # www.siebel.com 22 my $www_siebel_dns = 'www.siebel.com'; 23 my $www_siebel_ip = '64.181.189.55'; 24 my $www_siebel = nslookup(host => "$www_siebel_dns", type => "A"); 25 26 $hash{site} = $www_siebel_dns; 27 $hash{$www_siebel_dns}{ip_now} = $www_siebel_ip; 28 $hash{$www_siebel_dns}{ip_new} = $www_siebel; 29 30 # ebusiness.siebel.com 31 my $ebiz_siebel_dns = 'ebusiness.siebel.com'; 32 my $ebiz_siebel_ip = '64.181.189.50'; 33 my $ebiz_siebel = nslookup(host => "$ebiz_siebel_dns", type => "A" +); 34 35 $hash{site} = $ebiz_siebel_dns; 36 $hash{$ebiz_siebel_dns}{ip_now} = $ebiz_siebel_ip; 37 $hash{$ebiz_siebel_dns}{ip_new} = $ebiz_siebel; 38 39 # ftp.siebel.com 40 my $ftp_siebel_dns = 'ftp.siebel.com'; 41 my $ftp_siebel_ip = '64.181.143.36'; 42 my $ftp_siebel = nslookup(host => "$ftp_siebel_dns", type => "A"); 43 44 $hash{site} = $ftp_siebel_dns; 45 $hash{$ftp_siebel_dns}{ip_now} = $ftp_siebel_ip; 46 $hash{$ftp_siebel_dns}{ip_new} = $ftp_siebel; 47 48 49 for my $j ( keys(%hash) ){ 50 print "$j\n"; 51 print "$j -> $hash{$j}{ip_now}\n"; 52 print "$j -> $hash{$j}{ip_new}\n"; 53 }
In reply to Problem with Hash when Using Strict by Dru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |