# File stats ;)
code/monks> wc -l input.list
5202 input.list
# my way
code/monks> time perl -n -a -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{(split(/\|/))[9]}++' input.list
846 10.155.240.2
943 10.155.240.3
3413 10.155.240.1
0.160u 0.000s 0:00.15 106.6% 0+0k 0+0io 339pf+0w
# your way
code/monks> time perl -n -a -F\\\| -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{$F[9]}++' input.list
846 10.155.240.2
943 10.155.240.3
3413 10.155.240.1
0.310u 0.000s 0:00.30 103.3% 0+0k 0+0io 336pf+0w
####
# again stats...
code/monks> ls -l input.list
-rw-r--r-- 1 ericmc users 2477055 2003-04-09 21:42 input.list
code/monks> wc -l input.list
100202 input.list
# my way
code/monks> time perl -n -a -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{(split(/\|/))[9]}++' input.list
16046 10.155.240.2
17948 10.155.240.3
66208 10.155.240.1
2.720u 0.020s 0:02.73 100.3% 0+0k 0+0io 339pf+0w
# your way..
code/monks> time perl -n -a -F\\\| -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{$F[9]}++' input.list
16046 10.155.240.2
17948 10.155.240.3
66208 10.155.240.1
5.610u 0.010s 0:05.62 100.0% 0+0k 0+0io 336pf+0w
####
#!/usr/bin/perl
# update2: this is parse.pl
while (<>) {
$f = ( split('\|') )[9];
# this needs to get optomized..
($data{$f}->[0] = $f) =~ s/\.//g unless( $data{$f} );
$data{$f}->[1]++;
}
for ( sort { $data{$a}->[0] <=> $data{$b}->[0] } keys %data ) {
print "$data{$_}->[1]\t$_\n";
}
Sample run, Note after each run I go through and change one of the lines so that we arent running into OS caching.
# file statscode/monks> wc -l input.list 100202 input.list
code/monks> ls -l input.list
-rw-r--r-- 1 ericmc users 2410847 2003-04-09 22:11 input.list
# and the first way
code/monks> time perl -n -a -F\\\| -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{$F[9]}++' input.list
16046 10.155.240.2
17948 10.155.240.3
66208 39.39.39.39
5.490u 0.000s 0:05.49 100.0% 0+0k 0+0io 336pf+0w
# now for my first iteration without sorting..
code/monks> time perl -n -a -e'END { print "$v\t$k\n" while($k,$v)=each%h} $h{(split(/\|/))[9]}++' input.list
17948 10.155.240.3
66208 39.39.39.39
16046 40.40.40.40
2.750u 0.000s 0:02.74 100.3% 0+0k 0+0io 339pf+0w
# and now with the code from above...
code/monks> time ./parse.pl input.list
66208 39.39.39.39
16046 40.40.40.40
17948 41.41.41.41
2.190u 0.010s 0:02.26 97.3% 0+0k 0+0io 349pf+0w