Re: string comparison
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Fri, 14 Oct 2005 18:09:34 +0200
Jürgen Exner schreef:
> Perl has a perfectly fine eq operator for comparing strings. There is
> no need to launch the big and expensive RE gun
OK, but that argument vaporizes if the RE was or will be loaded for
other parts of the program anyway.
> and then jump through
> hoops to "make it work" (e.g. for RE special characters).
No need to jump through hoops:
if ($a =~ m/\A(apple
|banana
|orange
)
\z/x) {
(untested)
> Would be interesting to benchmark a simple eq in a loop versus the
> concatenated or'ed REs. My gut feeling is that the loop with eq will
> be much faster
Compiled simple regexes are also very fast. I'll try benchmark later.
--
Affijn, Ruud
"Gewoon is een tijger."
.
- References:
- Re: string comparison
- From: Dave Weaver
- Re: string comparison
- From: Dr.Ruud
- Re: string comparison
- From: Jürgen Exner
- Re: string comparison
- From: Dr.Ruud
- Re: string comparison
- From: Jürgen Exner
- Re: string comparison
- Prev by Date: FAQ 8.14 How do I modify the shadow password file on a Unix system?
- Next by Date: Re: Photo re-sizing code for member-base web site
- Previous by thread: Re: string comparison
- Next by thread: Re: string comparison
- Index(es):
Relevant Pages
|