I too am a huge fan of qr;
Ehrrmm, I see that you hardly need a lesson in how to use
qr.
:)
however, I think this situation is a perfect use of the /o operator.
I don't, especially since it doesn't work on ActivePerl.
:) But there's also another reason why I don't like to use it. As I've already said
here perl optimizes away recompilation in simple cases like this. As your benchmark shows there's not much difference between with and without the o modifier. So in this case I'd prefer not using it. And the reason for that is that I'm scared of myself. One day I might put the code in a subroutine. Another day I might change it to take arguments that I use in the regex. If I forget about the o -- and I most probably will -- it might take me a while to discover the bug. If I use
qr for this, or even nothing fancy at all, I won't get bitten.
I code with a lot of personal style and hints, and for me the o says "this is a dynamically set constant, and is supposed to be that way, so don't bother. It should never change. NEVER!". Often I don't mean that, and hence I use
qr instead. I'm scared of my own benchmark results though: (your code)
Benchmark: timing 1000 iterations of None, Slasho, qr...
None: 30 wallclock secs (30.08 usr + 0.14 sys = 30.22 CPU) @ 33.09/s
Slasho: 29 wallclock secs (28.74 usr + 0.02 sys = 28.76 CPU) @ 34.77/s
qr: 31 wallclock secs (30.49 usr + 0.00 sys = 30.49 CPU) @ 32.80/s
For me
qr is even worse. This does indeed surprise me.
Cheers,
-Anomo
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.