in reply to Re^2: 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
add another condition to the if/unless
poj#!/usr/bin/perl use strict; use XML::Simple; my $xml = do {local $/='';<DATA>} ; my $servers = XMLin($xml); my %seen=(); my @array=(); foreach my $server (@{$servers->{server}}) { my $lanip = $server->{LanIP}; $lanip =~s/\d+$/0/; push(@array, $lanip) unless ( $seen{$lanip}++ || $lanip eq ''); } print join "\n",@array; __DATA__ <xml> <server LanIP="192.169.30.123"/> <server LanIP=""/> <server LanIP="192.169.30.24"/> <server LanIP=""/> <server LanIP="192.169.31.126"/> <server LanIP="192.169.32.127"/> </xml>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: grep unique values , remove the blank spaces and store it in a variable
by brother_m (Initiate) on Sep 15, 2015 at 09:40 UTC |