Alistair,

No need to fall off of the horse, you will get bruised that way. Sometimes you have to 
point your horse in a different direction to
view the horizon. Note the following:

{
    use Benchmark;
    timethese(100000,
             {'sprintf' => sub {my $num = '00000.00';$num = sprintf('%1.2f',$num);},
              'regex'   => sub {my $num = '00000.00';$num =~ s/\b0+(?=\d)//;}});
}

returns:

Benchmark: timing 100000 iterations of regex, sprintf...
     regex:  2 wallclock sec ( 2.30 usr +  0.00 sys =  2.30 CPU) @ 43402.78/s 
(n=100000)
   sprint:  3 wallclock secs ( 2.39 usr +  0.00 sys =  2.39 CPU) @ 41788.55/s 
(n=100000)

I was quite surprised to see that the regex won out by a bit, I would have thought 
that it would have invoked more overhead. This
has been a learning experience, which is one of the aspects of this list that I enjoy.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to