in reply to grep unique values , remove the blank spaces and store it in a variable

Hello deep27ak, and welcome to the Monastery!

push(my @array, $lanip) if ! $seen{$lanip}++; print "@array\n";

The logic is wrong. This creates a new @array on each iteration of the foreach loop, conditionally populates it with a single element, and then prints it out whether it contains the element or not. You need something like this (untested):

my @array; 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(@array, $lanip) if ! $seen{$lanip}++; } print "@array\n";

Note also that use of the XML::Simple module in new code is discouraged — see STATUS-OF-THIS-MODULE of XML::Simple.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,