Practical Perl am Donnerstag, 9. März 2006 09.50: > Hello, > > I have a script,which run well at most time.This day I use it to analyse > the files of 1.7G,it become very slow and can't get executed continuely > anymore.When I run 'strace -p xxxx' (here xxxx is this script's PID),there > is no output,it seems died. > > Here is my script: > > #!/usr/bin/perl > use strict; > use warnings; > > my $date=`date +%y%m%d`; > chomp $date; > my $dir="/home/datas/loginIP"; # here stored about 140 files,which are > totally 1.7G. > my @files= glob "$date/*.ip"; > my (%low, %total); > > foreach my $file (@files) > { > open (FILE,$file) or die "$!"; > while(<FILE>) > { > next if /^192\.168\./; > next unless /^(\d+\.\d+\.\d+\.)(\d+)/; > $low{$1}{$2}=1 if $2 < 128; > > $total{$1}{$2}=1; > } > close FILE; > } > > > open (RESULT,">","dynamic.$date.re") or die "$!"; > > foreach (sort { scalar keys %{$total{$b}} <=> scalar keys %{$total{$a}} } > keys %total) > { > my $low = scalar keys %{$low{$_}}; > my $high = (scalar keys %{$total{$_}}) - $low; > > if ($low > 64 and $high > 64) > { > printf RESULT "%-25s%-20s\n", $_."0", $_."255"; > }elsif ($low > 64 and $high <= 64) > { > printf RESULT "%-25s%-20s\n", $_."0", $_."127"; > }elsif ($low <= 64 and $high > 64) > { > printf RESULT "%-25s%-20s\n", $_."128", $_."255"; > } > } > > close RESULT; > > ---- > > The files handled by the script are looked as: > > 211.139.227.247:3088 > 220.181.31.245:1134 > 220.181.31.247:1126 > 220.181.31.248:1120 > 220.181.31.246:1071 > 220.178.47.2:977 > 221.11.26.219:961 > 221.11.26.220:934 > 210.31.76.252:911 > ... > ---- > Why this happen and how to resolve it? Any suggestion is welcome.Thanks.
Do you have sufficient memory to hold all data in a hash and sort it? Does the box swap? Hans -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>