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

[MacPerl] ?pattern? and reset



I have to churn through around a gigabyte of text. After having sorted
out the basic algorithmic issues, I am now looking to optimize.

One of the more time critical operations is the dual pattern-matche
that I perform on each line of text with the following:

	unless (($curLine =~ /\[\d/) && ($curLine =~ /\"$\/\Z/))

Since I really need to know only whether these patterns are in the
string at all, I would prefer to use ?? rather than // patterns since,
if I replace the // delimiters with ?? delimiters, I see a 14%
performance improvement; unfortunately, the line of code also stops
working thereafter. Just to make sure, I printed out $& after the line
and it seemed to be matching the latter expression but not returning
true.

After some digging around, I discovered that ? patterns have the
irksome need for a reset after every use. When I added the necessary
resets, I found myself at 14% worse than when I started, ie 28% slower
than with the ? patterns.

Is there a way out of this dilemma that might not be apparent to a Perl
novice such as myself?

Stephan

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch