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.

JJ


In reply to strange uninitialized value problem by jjhorner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.