There's more than one way to do things | |
PerlMonks |
Re: Style question: regex versus string builtin functionby thospel (Hermit) |
on Oct 02, 2007 at 11:33 UTC ( [id://642075]=note: print w/replies, xml ) | Need Help?? |
I'd definitely go for the regex. If I later would read that code, I'd have to think for half a second about the index code to see that's it's not a "where is this needle", but that it's a "does the needle exist anywhere", while a regex immediately gives that kind of association. If index is faster, that is an implementation detail. If we care, we should just fix the perl optimization code to make them equivalent. But by default clarity not speed is the goal of writing code.
In Section
Seekers of Perl Wisdom
|
|