Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^5: Best practice or cargo cult?

by demerphq (Chancellor)
on Jun 22, 2006 at 07:44 UTC ( #556854=note: print w/replies, xml ) Need Help??

in reply to Re^4: Best practice or cargo cult?
in thread Best practice or cargo cult?

Well there are two reasons why I wouldnt do it this way. The first is that doing this afaict adds a high cost to compiling regexes in the scope where the overload takes effect. The second is that special metasequences like we are discussing can be handled much more efficiently by the regex engine. So for instance a NEOL regop would be a lot more efficient both in terms of storage and execution than the ANYOF regop that [^\n] is converted to.

The ANYOF is implemented by a bitmap lookup with flags, meaning it requires more than 32 bytes to represent, and for each character inspected requires a set of bit shifting to do the correct bitmap test. Wheras an NEOL regop would be much faster as it would essentially be a straight character inequality test. Also an NEOL regop would be just 4 bytes iirc.


Replies are listed 'Best First'.
Re^6: Best practice or cargo cult?
by diotalevi (Canon) on Jun 22, 2006 at 13:40 UTC

    This is nothing a little conditional can't cure. From a syntax standpoint, \N is the right symbol to use since \n means "newline" and we have the practice of saying \w|\W and \s|\S. I would think you'd either want to shuffle off the unicode name or just not do the work.

    sub import { if ( $] >= 5.010 ) { # Thanks to demerphq, this is native and the overloading isn't + needed. } else { overload::constant qr => \ &convert; } }

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://556854]
[stevieb]: debugged my first very low-level C memory issue within a shared library with gdb so I did :D
[stevieb]: problem was in my code, but through the debugger I figured out what was actually happening, and why. Pretty straight forward after a few hours of reading and testing

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-06-25 18:23 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (568 votes). Check out past polls.