Olivier Wirz wrote:
Hello,
What is the best way to convert a numeric cobol format S9(09)V9(04) in a more readable way.
How would we know? This is a Perl list. To some people here, the string above may be meaningful. To most, it is line noise. Try:
That's a signed number, with 9 digits before the decimal point and 4 after.
For example:
000001000000} will be -1000.0000 000001000000{ will be 1000.0000
Gazing way deep in my crystal ball, I'm going to intuit that those left and right braces are a COBOL signed value indicators. The problem is that you haven't said this.
Close: their the filesystem signed value indicators unpacked numeric records for COBOL files. Or at least this format of COBOL files.
It works with substr and =~, but may be there is a module or another better way.
Search CPAN using COBOL as a keyword, maybe. It will do little good to move code out of COBOL, though, if you carry COBOL thinking with you. Presuming that you know what the significance of place value operators, etc. are for COBOL, you could:
Read the COBOL output as strings, interpreting each string to its numerical value by the sysntactic rules you are familiar with. Output the numbers in Perl, since Perl's default output format is generally the natural expression of any numerical value.
Which is exactly what he is trying to do. In fact, it sounds like he already has a way to do it. He's just asking if there is a *better* way.
Practice thinking in full concepts, expressed in full words. You will get more long-term mileage out of this step than any code solution could possibly provide.
Joseph
He did. He's asking for semi-high level advice here: what is the *best* way to do a particular conversion. Anyone who can answer the question probably has done the conversion themselves, and would understand the few things he left unexplained. Anyone who couldn't understand what he left unexplained would have no answer; they've never done it. He explained enough to be clear, but not enough to be redundant. (Though I would like to know what system he is getting the file from, it could be pertinent.)
A search of CPAN for COBOL doesn't turn up anything particularly promising, but that is occasionally the case. Modules are sometimes hard to find, and may not be under the obvious-at-the-time keywords.
This is a common question class on this list. I see it often: some question that the details of make little or no sense to me, but does to people who know what the poster is talking about. The general population of the list may or may not be able to answer, but the poster is looking for those few who *can* answer. They provide enough for someone who knows the problem space can answer, but don't bother to define everything because it would bore people, and not get any better answers.
There are a few of us here who will admit to knowing COBOL. We can answer the question as asked. For those who don't, Oliver can probably do as good a job of coding a conversion routine as they can.
Daniel T. Staal
--------------------------------------------------------------- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. ---------------------------------------------------------------
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>