Hi Anyone can help me??i writing a perl using array to translate ip address to the hostname my script are below.this line print "$myhost{$ipaddr}\n"; blank
hostname dint come out
#!/usr/local/bin/perl
@ipaddr=("192.1.168.2","172.25.1.13","129.1.2.5");
%myhost = { 192.1.168.2 =>"Machine 1",172.25.1.13=>"Machine 2",129.1.2.5=>"Machine 3");
foreach $ipaddr(@ipaddr){
print "$ipaddr\n";
print "$myhost{$ipaddr}\n";
}
---------- Post updated at 11:22 AM ---------- Previous update was at 11:16 AM ----------
fyi i have try
print "$myhost{192.1.168.2}";
supposely come out Machine 1 but nothing comeout...blank!!
.anyone pls help me..
---------- Post updated at 11:25 AM ---------- Previous update was at 11:22 AM ----------
this line print "$ipaddr\n"; no problem can print out the ip addre
192.1.168.2
172.25.1.13
129.1.2.5