Re: [QUIZ] Perl 'Easy' Quiz of the Week #2005-1 (benchmarking: sorry)
Ronald J Kimball <[email protected]> Mon, 31 Jan 2005 01:14:13 -0500
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Jan 30, 2005 at 11:46:10PM +0100, David Jones wrote: > This can be (very) slightly improved by compiling the regex just once > (replace the body of the while loop with the following): > > my ( $pref, $suff ) = /(\w+)\.([A-Z])/o; > > Average time: 45 seconds It's a constant regex, so it's only compiled once anyway. /o is a no-op if the regex doesn't interpolate any variables. Ronald