John McKown <[EMAIL PROTECTED]> wrote:

> FWIW - the best thing, IMO, is to change the generating program's
> PIC 
> clause to:
> 
>       PIC S9(09)V.9(04) SIGN IS LEADING SEPARATE.
> 
> This will take up two more characters in the output line. It will
> insert 
> an actual decimal point and prefix the number with a + or a -
> sign. Much 
> easier to process in a non-COBOL language.
> 
> Sorry if this COBOL-talk offends any Perl-ites <grin>.

Doesn't offend me ... we use COBOL, PERL and Java in our shop.

> On Sat, 10 Jan 2004, Olivier Wirz wrote:
> 
> > Hello,
> > 
> > What is the best way to convert a numeric cobol format
> S9(09)V9(04) in a more readable way.
> > 
> > For example:
> > 
> >  000001000000} will be -1000.0000
> >  000001000000{ will be  1000.0000 

The problem with the above is that you do not know where the
decimal point is.  I'm assuming this is in an ASCII file (hence the
curley braces).  Also there is no implication if these are COMP
fields or not.  Even so, the code you write will not be completely
portable:  A COMP-5 [binary] value with a negative sign will have a
lower case 'p' instead of '}' if using Microfocus COBOL.

I would just build a small conversion routine to parse and
interpret according to how you expect it.  For this to be on CPAN
would be too general I think....

> > It works with substr and =~, but may be there is a module or
> another better
> > way.
> > 
> > Thank you.
> > 
> > Olivier 

HTH,

-JW


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to