Steve Dawson wrote:
> 
> While Bill and I both suggested the split (me because I thought it was 
> faster and more clearly expressed), I was bored and decided to work out 
> just how much slower the regex would be. Having now benchmarked 8 
> variations. I have to say "I was wrong".

The RE is going to be faster and more appropriate for very large files
because it doesn't have to create the field arrays.  For small files
or low data counts I'd still use the simpler split since it's more
versatile.

> On a 6MB test file, The regex ran in 2.48secs while my split ran in 
> 6.19secs. Here's the variations I tried and the timings...
> 
> 1) My version of the split: *6.19s*    
> @columns = split /\"\s+\"/

This one is faster than below, but doesn't handle field 1 and n.
You could also use something like: split /\s*("[^"]+")\s*/   untested.
And toss every other field (even fields).

> 2) Bill's most recent version: *9.34s*     
> @columns = split /"\s+"|^"|"$/

This one allows for spaces.


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to