working with binary data in Perl...

Lance F. Squire lance-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Fri Sep 29 19:42:35 UTC 2006


I'm attempting to wright a conversion program for an old byte oriented 
picture description language (NAPLPS/Telidon) to SVG.

I currently have a script in Perl that will give me a human readable 
output from a NAPLPS file. However the code looks like it could have 
been written in BASIC.

eg:

if ( $Byte eq "\e" ) { $Desc = "ESCAPE"; }
elsif ( $Byte eq chr(15) )
	{
	$Desc = "SHIFT-IN - SETTING 'GL' TO 'ASCII (G0)'";
	$GL = "ASCII";
	}
elsif ( $Byte eq chr(14) )
	{
	$Desc = "SHIFT-OUT - SETTING 'GL' TO 'PDI (G1)'";
	$GL = "PDI";
	}

And doing bit shifts gets really interesting...

#Correcting for missing bytes
$Pel{X} = chr(ord($Pel{X})<<$Shift);
$Pel{Y} = chr(ord($Pel{Y})<<$Shift);

My question is: Is there a more elegant way to work with the binary data 
in Perl?

Lance F. Squire
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list