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

Re: [MacPerl] Bug report on 5.14b1 (fwd)



At 17.46 8/13/97, Mark Manning/Muniz Eng. wrote:
>Chris answered this question for me quite
>clearly.  The "eq" is quite a bit faster than the "=~"
>statement and I _do_ plan on changing over several
>statements in programs to it.

One more note: if there does happen to be more than one variation of MacOS
perl at some point, it would still likely be faster -- and better, meaning
less likely to foul up -- to use eq:

        if ($^O eq 'MacOS' || $^O eq 'Mac OS') { BLOCK }

However, you could carefully craft a regex to do something similar.
Possiblities:

/^(?:MacOS|Mac OS)$/
/^MacOS|Mac OS$/
/^Mac ?OS$/
/^Mac( ?OS.*|intosh.*)?$/

Obviously, to best craft the regex, you need to know exactly what the
possibilities might be.  And given a small number of possibilies, the OR'ed
eq still works fastest (though it takes longer to write, and the difference
in execution over 1,000,000 iterations is significant, but at 10,000 or
less is not significant).

But the point that you need to craft the regex precisely in order for it to
be useful is not lost.  Use string anchors ^ and $ and, if possible, allow
only those possibilites which you want to allow.  /^Mac.*/ might allow
MachTen, as already stated.  But /^Mac( ?OS.*|intosh.*)?$/ will only allow
Mac, MacOS.*, Mac OS.*, and Macintosh.* (meaning that if you get to MacOS,
Mac OS or Macintosh, what follows might not matter).

I might have made a mistake in a regex above (I didn't fully check them
all), but hopefully the principle is there.  /mac/ or /mac/i is not
suffcient, but that does not preclude using the regex operators, when
applied properly.

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])



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