Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: (jeffa) Re: (USING POE!) Re: 'better mousetrap': how to perform timed event

by eduardo (Curate)
on Apr 24, 2003 at 03:39 UTC ( #252757=note: print w/ replies, xml ) Need Help??


in reply to (jeffa) Re: (USING POE!) Re: 'better mousetrap': how to perform timed event
in thread 'better mousetrap': how to perform timed event

Ah yes... \Q and \E. I'll be honest, I'm not nearly crafty enough with regular expressions to have thought of that. As far as my perling goes, it has been rather surprisingly devoid of regular expressions. I've probably written 20-30k lines of perl code in my life, and alltogether, I've probably written 50 regular expressions in my code. Ah well, that's what we have maverick for :)

I am however curious about the /o modifier on the re. I mean, if we know the "event" that the user is looking for, what is the reason for *not* using it? After all, as the code has been specified, it's a non-mutable trigger... is it simply an issue of pre-emptive maintenance coding headache prevention? I don't think I know tye nearly well enough to just badger him needlessly when I have you to thwack about :)


Comment on Re: (jeffa) Re: (USING POE!) Re: 'better mousetrap': how to perform timed event
(jeffa) 3Re: (USING POE!) Re: 'better mousetrap': how to perform timed event
by jeffa (Chancellor) on Apr 24, 2003 at 05:52 UTC
    Heh heh ... thwack away! ;)

    "... is it simply an issue of pre-emptive maintenance coding headache prevention?"

    I think so. What if you suddenly decide that the string you need to match needs to be dynamic? You forget to remove the o modifer and possibly spend a lot of time trying to find the bug when your regex stops matching. Here is some code to demonstrate:
    @data = qw(foo bar baz qux); { print "search: "; chomp ($in = <STDIN>); last unless $in; print $_,$/ for grep /\Q$in\E/o, @data; redo; }
    I figure why bother with such premature optimizations if they have the potential to bite.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      yet another perfectly usable, very useful facility of perl consigned to the bit-bucket of jaundiced opinion because one self-ascribed expert got bitten by it once.

        Sorry, you are totally wrong.

        1. You are posting as Anonymous Monk. If you feel you have to make that kind of opinionated statement, log in. Yes, you will be downvoted, but PerlMonks is not about XP, right?

        2. jeffa never denied the general usefulness of the /o modifier. He merely states it bothers him, and gave a good explanation why. He even called his own behaviour "cargo-cultish", which should be enough to tell you that he doesn't want to push /o in the bit bucket.

        3. jeffa probably doesn't need to be "jaundiced". He is a long-standing member of PerlMonks and an experienced programmer. Not everybody plays silly games all the time.

        4. He didn't call himself an expert.

        5. IMHO, it is clever to only get bitten once, and then think about it. Not that he mentioned that he only got bitten once, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://252757]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-12-19 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls