[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Hoaky MacPerl Regular Expression Question



On Fri, 14 May 1999, Richard K. Moore wrote:

> BTW> a question... is split always to be preferred to regex??  Is it
> significantly faster?  Do you lose very much of the advantage due to the
> storage allocation that's required for the split list?

With Perl (not just MacPerl) you have to redefine your understanding as to
what is fast and what isn't. One thing (and this clashes with how you
would do things in C, generally) is that usage of builtins (like 'split')
is NOT (usually) a performance hit.

I would use split where it can be used, to solve a problem that requires
cutting up a string. Benchmarking shows that it is indeed usually faster
than using regexes.

If the problem involves a deployed app and not just a one-off I'd try both
approaches and see what works faster. Don't forget to leverage the R.E. as
much as you can by using the /o modifier (if possible), avoiding the bad
variables like $`, etc etc.

Arved



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org