HP3000-L Archives

June 2002, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Michael Abootorab <[log in to unmask]>
Reply To:
Michael Abootorab <[log in to unmask]>
Date:
Mon, 10 Jun 2002 15:02:18 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (32 lines)
Hi,

a few weeks ago I saw a questiion about using perl to convert
 packed decimal fields (COBOL comp-3 ) to decimals.

the following perl fuction will do the job on HP3000 and HP9000 processors:

sub pack2dec {

 my $packfield = shift;
 my $num = unpack('H*',$packfield);
 my $sign = 1;

if ( $num =~ /[FD]/ ){
   $sign = -1;
}

$num =~ s/\D.*//g;

$num = $sign * $num;


return $num;

}

thanks
Michael

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2