Re: compiling Perl on Win32 so I can use Inline::C
by BrowserUk (Patriarch) on Mar 03, 2005 at 04:10 UTC
|
If you grab the MS VC++ compiler, you can use Inline::C in combination with ActiveStates pre-built binaries. Saves a bunch of hassle.
Then again, once you have MS VC++, building Perl yourself is considerably easier anyway.
That said, why read a byte at a time? If your frames are fixed length, read or sysread a frame's worth of bytes and process the buffer a byte at a time. Then you can use Perl's string-wise and, or exlusive or and not to process whole strings together if that fits your purpose. And if not, you can always drop into C for that bit and leave the filehandling to perl.
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
| [reply] [d/l] |
|
|
Wow, I really appreciate everyone's comments! I can't assume fixed frame length or even that a frame begins on the first bit. I wanted to use Perl for its cool data structures and file I/O... Not giving up yet... :)
| [reply] |
|
|
| [reply] |
Re: compiling Perl on Win32 so I can use Inline::C
by thor (Priest) on Mar 03, 2005 at 01:34 UTC
|
I have no experience in compiling perl. However, I find that your statement of "I'm processing binary data" sets off a trigger with me. Perl has facilities for dealing with binary data. I've written a couple of modules at work to do just that. You don't need C to do this, so if that's your only reason for this trek, perhaps you could pose your problem for the monks at large to answer...
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
| [reply] |
|
|
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)
| [reply] |
|
|
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
| [reply] [d/l] [select] |
Re: compiling Perl on Win32 so I can use Inline::C
by PodMaster (Abbot) on Mar 03, 2005 at 01:53 UTC
|
| [reply] |
Re: compiling Perl on Win32 so I can use Inline::C
by dragonchild (Archbishop) on Mar 03, 2005 at 13:31 UTC
|
I strongly urge you to reexamine your assumption that you have to use C to do this task. Anything C can do, Perl can also do, and usually without dropping into XS. When it comes to binary data, pack and unpack are your friends. read and sysread are also very helpful, though standard file I/O can also be used if you set $/ to a number indicating how many bytes to read at a time.
Alternately, you can install Cygwin and just do it in Unix. :-)
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
Re: compiling Perl on Win32 so I can use Inline::C
by zentara (Cardinal) on Mar 03, 2005 at 12:44 UTC
|
I'm using Win XP.....is ridiculously complicated....about ready to throw the whole thing out the window.... Switch to Linux, and your world will once again become beautiful.
I'm not really a human, but I play one on earth.
flash japh
| [reply] |
| A reply falls below the community's threshold of quality. You may see it by logging in. |