Now I have resolved this problem,still using perl.
Just a little modification to that code,shown as below:
foreach my $file (@files)
{
open (FILE,$file) or die "$!";
while(<FILE>)
{
next if /unknown/o;
next if /^192\.168\./o;
next unless /^(\d+\.\d+\.\d+\.)(\d+)/o;
if ( $2 < 128 ) {
$low{$1}{$2}=1;
}
$total{$1}{$2}=1;
}
close FILE;
}
open (RESULT,">","allIP.txt") or die "$!";
for ( sort { scalar keys %{$total{$b}} <=> scalar keys %{$total{$a}} } keys
%total ) {
print RESULT "$_\t", scalar keys %{$low{$_}}, "\t",
(scalar keys %{$total{$_}}) - (scalar keys %{$low{$_}}), "\t",scalar
keys %{$total{$_}}, "\n";
}
close RESULT;
Now it run very fast,get the results in 20 minutes.Thanks for all.
On 12/9/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
>
> 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>
>
>
>