内容略,评测代码如下:
open my $fh, "<", "$Bin/res/apache.log" or die "apache.log: $!"; my @data=<$fh>; timethese( 10000000, { 'Common IP' => q{ foreach(@data) { my ($ip) = m/^($RE{net}{IPv4})/; } }, 'Person IP1' => q{ foreach(@data) { my ($ip) = m/^([0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,})\s+/ ; } }, 'Person IP2' => q{ foreach(@data) { my ($ip) = m/^([0-9.]{7,})\s+/ ; } }, } ); close $fh;