in reply to Program to convert Numeric text file to Packed decimal file

Assuming that by "packed decimal" you mean COBOL style COMP3, try this (unverified):

sub iToComp3 { my $num = '' . shift; ## force to string ## Add padding to even length strings ## to accomodate trailing sign bits $num = '0' . $num unless length( $num ) & 1; my $comp3 = ''; ## pack each digit into 4 bits of output vec( $comp3, $_, 4 ) = substr( $num, $_, 1 ) for 0 .. length( $num ) - 1; ## Add sign bits (doesn't cater for unsigned COMP3!) vec( $comp3, length( $num ), 4 ) = $num < 0 ? 0x0D : 0x0C; return $comp3; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."