HI 

I have a script that reads stdin from the output of another script and cleans it up 
and prints it. The script gets ip's.

I would like to sort it and and eliminate duplicates count the sorted/unique ips then 
print???

I thought using the perl sort command would help but it did not... I could pipe the 
output to /bin/sort -u, but I wanted to do everthing in perl. 

Help if you can. 

#!/usr/bin/perl
use strict;
my $count = 0;
 
   while( <> ) {                       #read from stdin one line or record at a time
 
s/ipadd://;                              #if line has ipadd: remove it
s/^ |\t//;                                #if any whitespace at the beginning of 
string rm
next if ($_=~/^\s*(\*|$)/);      #if line begins with a *
 
print sort $_;
$count ++;                             # Count
 
  }
print "\n";
print "Total IP'S = $count\n";



Current out:
111.222.81.97
111.222.81.97
111.111.135.11
 
Total IP'S = 3


Goal Out:
111.111.135.11
111.222.81.97
 
Total IP'S = 2


Thanks,
rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to