jjhorner has asked for the wisdom of the Perl Monks concerning the following question:
Will someone tell me why this:
#!/usr/bin/perl -w use strict; use Benchmark; my $log = "205.188.209.11 - - \[02/Jun/2000:00:30:00 -0400\] \"GET /lm +es/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)' });
Gives this:
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)
I know that I have the iterations set to 1, but that is so I won't have a ton of crap on my screen while I'm fixing this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: strange uninitialized value problem
by swiftone (Curate) on Jun 02, 2000 at 21:53 UTC | |
by jjhorner (Hermit) on Jun 02, 2000 at 21:54 UTC | |
by swiftone (Curate) on Jun 02, 2000 at 21:57 UTC | |
|
Re: strange uninitialized value problem
by Fastolfe (Vicar) on Jun 03, 2000 at 01:15 UTC | |
by chromatic (Archbishop) on Jun 07, 2000 at 01:46 UTC |