Jennifer Garner wrote:
> Hi,John

Hello,

> I think you have  understanded wrongly with my meaning.
> The result of  $low{ $1 }++ is no use for me.I just want the frequency of IP
> exists.
> For example, if there are some IPs exists in '22.33.44.0' :
> 
> 22.33.44.11
> 22.33.44.22
> 22.33.44.22
> 22.33.44.33
> 22.33.44.33
> 22.33.44.44
> 22.33.44.55
> 
> Now I only want  the uniq times of all IP appeared,this is 5.

Do you mean something like this:

use Socket;

my ( %seen, %total );
while ( <FILE> ) {
    next if /unknown/;
    next if /^192\.168\./;

    next unless /^(\d+\.\d+\.\d+\.\d+)/;

    my $ip = inet_aton $1;

    $total{ $ip & "\xFF\xFF\xFF\0" }++ unless $seen{ $ip }++;
    }

close FILE;

for ( sort { $total{ $b } <=> $total{ $a } } keys %total ) {
    print RESULT inet_ntoa( $_ ), "\t", $total{ $_ }, "\n";
    }




John
-- 
use Perl;
program
fulfillment

-- 
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