Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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

Replies are listed 'Best First'.
(jeffa) 3Re: (USING POE!) Re: 'better mousetrap': how to perform timed event
by jeffa (Bishop) 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.


    (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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2022-10-06 07:59 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (26 votes). Check out past polls.