On 9/29/06, <b class="gmail_sendername">Lance F. Squire</b> <<a href="mailto:lance-5ZoueyuiTZhBDgjK7y7TUQ@public.gmane.org">lance-5ZoueyuiTZhBDgjK7y7TUQ@public.gmane.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm attempting to wright a conversion program for an old byte oriented<br>picture description language (NAPLPS/Telidon) to SVG.<br><br>I currently have a script in Perl that will give me a human readable<br>output from a NAPLPS file. However the code looks like it could have
<br>been written in BASIC.<br><br>eg:<br><br>if ( $Byte eq "\e" ) { $Desc = "ESCAPE"; }<br>elsif ( $Byte eq chr(15) )<br>        {<br>        $Desc = "SHIFT-IN - SETTING 'GL' TO 'ASCII (G0)'";
<br>        $GL = "ASCII";<br>        }<br>elsif ( $Byte eq chr(14) )<br>        {<br>        $Desc = "SHIFT-OUT - SETTING 'GL' TO 'PDI (G1)'";<br>        $GL = "PDI";<br>        }<br><br>And doing bit shifts gets really interesting...
<br><br>#Correcting for missing bytes<br>$Pel{X} = chr(ord($Pel{X})<<$Shift);<br>$Pel{Y} = chr(ord($Pel{Y})<<$Shift);<br><br>My question is: Is there a more elegant way to work with the binary data<br>in Perl?
</blockquote><div><br></div></div>I wonder if it wouldn't be easier to write this in C, since so much of it is doing binary operations.<br><br>You could either write the whole thing in C, or a hybrid Perl/C program to give you the flexibility of Perl with the speed of C.
<br><br>I don't have experience with the hybrid, but I have lots of experience with Perl and with C, and I hear that Inline::C works really well.<br><br>Just a thought.<br><br>-- <br>Alex Beamish<br>Toronto, Ontario<br>
<br>