deep27ak has asked for the wisdom of the Perl Monks concerning the following question:
Here as you see I am substituting the last digit of the IP with '0' which gives me a bunch of IPs but I only want to grep unique IPs. With current script I get below output#!/usr/bin/perl -w use strict; use XML::Simple; my $servers = XMLin('file.xml'); my %seen; foreach my $server (@{$servers->{server}}) { my $node = $server->{Node} . "\n"; my $lanip = $server->{LanIP} . "\n"; my $mask = $server->{Netmask} . "\n"; substr($lanip, 11, 3) = "0"; push(my @array, $lanip) if ! $seen{$lanip}++; print "@array\n";
192.169.30.0 192.169.31.0 192.169.32.0 192.169.72.0
Lots of blank spaces. I want to remove them and store it into a global variable/array which can be used later.
The output should be something like belowAlso if possible I am trying to do this without List::MoreUtils Module.192.169.30.0 192.169.31.0 192.169.32.0 192.169.72.0
|
|---|