in reply to Re: compiling Perl on Win32 so I can use Inline::C
in thread compiling Perl on Win32 so I can use Inline::C

Why thank you, kind thor. Can Perl read one byte at a time, do bit-shifts and ands and ors to find a sync pattern, and then translate the binary to hex and then apply a decimal conversion formula to that hex data? And fast? If so, then no, I don't need C. (I'm processing frames of spacecraft telemetry in a sort of home-grown, let's figure out how to do this ourself research atmosphere)
  • Comment on Re^2: compiling Perl on Win32 so I can use Inline::C

Replies are listed 'Best First'.
Re^3: compiling Perl on Win32 so I can use Inline::C
by mlh2003 (Scribe) on Mar 03, 2005 at 03:38 UTC
    In one word, YES.

    Read 1 byte at a time:

    read() # when reading from a file, or unpack() # using b or B in the template when reading from a string

    Bit shift left 3 bits:

    $a = $b << 3;

    Bit shift right 2 bits:

    $a = $b >> 2;

    Bitwise AND:

    $c = $a & $b;

    Bitwise OR:

    $c = $a | $b;

    Bitwise XOR:

    $c = $a ^ $b;

    Binary to hex conversion (4 bits at a time):

    $hex =~ s/([01]{4})/sprintf("%.1x", eval('0b'.$binary))/eg;
    (or something similar using the sprintf function)

    --------------------
    mlh2003