#!/usr/bin/perl -w use strict; use Benchmark; my $log = "205.188.209.11 - - \[02/Jun/2000:00:30:00 -0400\] \"GET /lmes/elements/eshome-5-y12-b.jpg HTTP/1.0\ " 200 2072"; sub regexp { my ($source,$timestamp,$method,$uri,$status,$bytes) = /^(\S+) \S+ \S+ \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+)/; } sub do_split { my @fields = split; $fields[3] =~ s/\[//; $fields[4] =~ s/\]//; my $timestamp = $fields[3]; my $source = $fields[0]; my $status = $fields[$#fields-1]; $fields[5] =~ s/\"//; $fields[7] =~ s/\"//; my $method = $fields[5]; my $uri = $fields[6]; my $protocol = $fields[7]; } timethese(1, { by_regexp => 'regexp($log)', by_split => 'do_split($log)' }); #### Benchmark: timing 1 iterations of by_regexp, by_split... by_regexp: 0 secs ( 0.00 usr 0.00 sys = 0.00 cpu) (warning: too few iterations for a reliable count) Use of uninitialized value at ./bench2.pl line 14. Use of uninitialized value at ./bench2.pl line 15. Use of uninitialized value at ./bench2.pl line 19. Use of uninitialized value at ./bench2.pl line 20. by_split: 0 secs ( 0.00 usr 0.00 sys = 0.00 cpu) (warning: too few iterations for a reliable count)