in reply to Re^3: is index faster than regexp for fixed text token?
in thread is index faster than regexp for fixed text token?

I agree; I like the Perl way better because it is more expressive and readable, plus it makes more sense to my XOR-incapable neurons. (Actually, I heard a lecture somewhere that neuron dendrites compute analog boolean-like operations such as AND and NOT on their neural inputs).

SSF

  • Comment on Re^4: is index faster than regexp for fixed text token?

Replies are listed 'Best First'.
Re^5: is index faster than regexp for fixed text token?
by Marshall (Canon) on Jul 13, 2009 at 00:27 UTC
    Great! Glad that we agree that ($B,$A)=($A,$B) is FAR superior the XOR trick! Clarity is an important aspect of software engineering.

    XOR is fundamental to data encryption and error correction codes. But for the most part, you won't need to use this in your normal code!!

    This is a bit off topic as this is 'C' Code, but just to show you another tricky way of using XOR in a low level sub. This is basically "modem code" as it looks like the gibberish that would result from an unsync'd modem!!

    Low level C has stuff like this, but almost no Perl code should have it! Heck the raw assembly code is easier to understand this this critter below, but this idiomatic good C code. enjoy.

    /* flip all bits except between range defined by startBit and numBits to left*/ /* bit numbering like: 7 6 5 4 3 2 1 0 */ inline unsigned short flipNotInRange (unsigned short in, int startBit, + int numBits) { unsigned short result; result =(~in) ^ (~((unsigned short) ~0<<numBits )<< startBit); return result; }