Hi.
I believe the following will do the packed decimal to integer conversion (It is based on code
I wrote in a differrent language). Since I currently do not have access to files containing
packled decimal my testing has been somewhat limited). The code is not blazingly fast
but I hope it is correct. Perhaps an optimized version warrants a CPAN module since.
Jonathan Finger
sub convert_pack_decimal_to_int
{
my $input = shift;
my $output = "";
if (length($input))
{
my $byte = ord(substr($input, -1, 1));
my $sign = 1;
if ($byte % 16 == 13)
{
$sign = -1;
}
substr($input, -1, 1) = chr(int($byte/16) * 16);
while (length($input))
{
my $byte = ord($input);
my $high = int($byte/16);
my $low = $byte % 16;
if (($high !~ /^\d$/) || ($low !~ /^\d$/))
{
die "Not valid packed data";
}
substr($input, 0, 1) = "";
$output .= "$high$low";
}
substr($output, -1, 1) = "";
$output *= $sign;
}
return($output);
}_________________________________________________________________
Enter for your chance to IM with Bon Jovi, Seal, Bow Wow, or Mary J Blige using MSN Messenger http://entertainment.msn.com/imastar
_______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm

