in reply to Re^3: grep unique values , remove the blank spaces and store it in a variable
in thread grep unique values , remove the blank spaces and store it in a variable

The substitution of 0 is indeed mysterious, and indeed substr would not help for 192.169.30.24.

Probably the programmer would like to split network number from host part for IPv4 addresses. Dotted quad notation is for the readers convenience, manipulation is better done in binary. Replacing the last quad only works for a mask of 255.255.255.0 and 192.169.30.214/28 would not be split properly.
The following strips off the host part, but would not work for IP v6
use Socket; ... my $addr = $server->{LanIP}; my $mask = my $mask = $server->{Netmask}; my $netaddr = inet_ntoa(inet_aton($mask) & inet_aton($addr)); push(@array, $netaddr) unless $seen{$netaddr}++;
  • Comment on Re^4: grep unique values , remove the blank spaces and store it in a variable
  • Download Code