"J. Horner" wrote:
> Sorry, it is a Monday.  I attached the right file.

You're problem is that you have toomuch other junk in addition to the
statements you're trying to compare.  Also, the strings you're matching
against are all so short that you wont see much difference between an
anchored and unanchored regex.

If you want to see the timing advantage demonstrated, try something like
this instead:

use Benchmark;

my $iter = 10000;
my $listsize = 100;
my @internals = ();

sub make_rand_str (;$) {
    my $maxstr = shift || 200;
    my $str = '';
    for (1 .. int(rand($maxstr)+1)) {
        $str .= chr( ord(' ') + int(rand(127-ord(' '))) );
    }
    return $str;
}

for (1 .. $listsize) { push @internals, make_rand_str(); }

sub unanchored { grep { /134\.167/ } @internals; }
sub anchored   { grep { /^134\.167/ } @internals; }

timethese($iter, { unanchored => 'unanchored()', anchored =>
'anchored()',  });

-- 
Devin Ben-Hur     | President / CTO  | mailto:[EMAIL PROTECTED]
The eMarket Group | eMerchandise.com | http://www.eMerchandise.com
503/944-5044 x228 | 
"Where do you want to go today?"
   "Confutatis maledictis, flammis acribus addictis"
   (The damned and accursed are convicted to the flames of hell)

Reply via email to