sinhass has asked for the wisdom of the Perl Monks concerning the following question:
I am new to perl programming and trying to learn to do perl way. I have a 300000 lines text files and trying to extract the IP information and remove the duplicate IPs. So far I am getting all the IPs but it doesn't remove the duplicates. Here is the code.
#!/usr/bin/perl use warnings; use Regexp::Common qw/net/; open (NMAP_DATA, "@ARGV") or die "Please type the filename. $!" ; open (IP_DATA, ">ipdata") or die "can't write to ipdata file"; while (<NMAP_DATA>) { my @ip_address = sort $1, "\n" if /($RE{net}{IPv4})/; print IP_DATA @ip_address if (!/^\s*$/); } close (IP_DATA) ; close (NMAP_DATA);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to remove duplicate IPs
by rjt (Curate) on Aug 07, 2013 at 22:53 UTC | |
by sinhass (Initiate) on Aug 07, 2013 at 23:05 UTC | |
Re: How to remove duplicate IPs
by jwkrahn (Abbot) on Aug 08, 2013 at 00:41 UTC | |
by sinhass (Initiate) on Aug 08, 2013 at 03:15 UTC |
Back to
Seekers of Perl Wisdom