Hi,
I have been working on a writing a script to compare host information from two different sources looking for differences. So far it is working fairly well except the final logical && statement seems to fail. The two things I am trying to check for is if the host is on the same network in both lists, and then I am checking to see if it is the same subnet in both lists. This is the particular line that is failing: if(($dhcp{$wrkst}-{network} eq $ipdb{$wkrst}->{network}) && ($dhcp{$wrkst}->{subnet} eq $ipdb{$wkrst}->{subnet})) And here is the script in its entirety so far. #!/usr/bin/perl system "clear"; use Text::DHCPparse; my $return; my %dhcp; my %ipdb; $return = leaseparse('dhcpd.leases'); foreach (keys %$return) { ($ip, $time, $mac, $name) = unpack("A17 A21 A19 A30", $return->{$_}); my ($range) = $ip =~ /(\d{1,3})$/; my ($network) = $ip =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3})/; if ($range >= 128) { $dhcp{$name} = { ip => $ip, mac => $mac, subnet => hi, network => $network,} } else { $dhcp{$name} = { ip => $ip, mac => $mac, subnet => low, network => $network,} } } my $ipdb_hosts = 'hosts.txt'; open (IN, $ipdb_hosts); while ($line = <IN>) { chomp $line; next if ($line =~ /^\s*#/); my(@host_array) = split / /, $line; my $name = $host_array[2]; my $ip = $host_array[5]; my ($range) = $host_array[5] =~ /(\d{1,3})$/; my ($network) = $host_array[5] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3})/; if ($range > 127) { $ipdb{$name} = {ip => $ip, network => $network, subnet => 'hi',}; }else{ $ipdb{$name} = {ip => $ip, network => $network, subnet => 'low',}; } } foreach my $wkrst (keys %dhcp) { if(($dhcp{$wrkst}-{network} eq $ipdb{$wkrst}->{network}) && ($dhcp{$wrkst}->{subnet} eq $ipdb{$wkrst}->{subnet})) { print "$wkrst is a match!\n"} else { print "in the dhcp lease file I found $wkrst with ip addr $dhcp{$wkrst}->{ip} on subnet $dhcp{$wkrst}->{subnet} on network $dhcp{$wkrst}->{network}\n"; print "in the ipdb I found $wkrst with ip addr $ipdb{$wkrst}->{ip} on subnet $ipdb{$wrkst}->{subnet}\n"; } } The following is a sample of the the two data sources one is basically a dhcp leases file and the other is the output from another script. Dhcp leases example # All times in this file are in UTC (GMT), not your local timezone. This is # not a bug, so please don't ask about it. There is no portable way to # store leases in the local timezone, so please don't request this as a # feature. If this is inconvenient or confusing to you, we sincerely # apologize. Seriously, though - don't ask. # The format of this file is documented in the dhcpd.leases(5) manual page. # This lease file was written by isc-dhcp-V3.0pl2 lease 10.10.9.128 { starts 3 2005/11/30 17:59:34; ends 3 2005/11/30 21:59:34; tstp 3 2005/11/30 21:59:34; binding state free; hardware ethernet 00:0b:97:2b:f0:4f; uid "\001\000\013\227+\360O"; client-hostname "HOST1"; } lease 10.10.12.12 2 { starts 2 2005/12/20 16:10:51; ends 2 2005/12/20 20:10:51; tstp 2 2005/12/20 20:10:51; binding state free; hardware ethernet 00:0b:97:2b:ea:fe; uid "\001\000\013\227+\352\376"; client-hostname "HOST2"; } lease 10.10.97.170 { starts 0 2005/12/25 23:08:02; ends 1 2005/12/26 03:08:02; tstp 1 2005/12/26 03:08:02; binding state free; hardware ethernet 00:0b:97:2b:ea:54; uid "\001\000\013\227+\352T"; client-hostname "HOST3"; } Script generated output # Host info including names and ip addr # # # HOSTNAME HOST IP Host is HOST1 Subnet is 10.10.12.1 Host is HOST2 Subnet is 10.10.9.128 Host is HOST3 Subnet is 10.10.14.128 Thanks, -angus