What are we talking about? Show us the code. Well, ok.

Is this what usage could look like?

DISCLAIMER
The COBOL might be a bit rusty (1987) and the perl is definitely a little speculative :-) so if I made mistaeks please correct them, but do not bother to check matching ({[< and the like - I didn't - the code is not meant to be run yet. It is meant to illustrate the questions and comments below the code.

#!/usr/bin/perl -w # ModuleWithAcceptableNameThatReflectsThePurpose Q1 use COBOLstorage; $datafile="somepathtothedata.coboldata"; $COBOLrecord = <<'FD1'; # C1 * paymenttrack-file 01 Payment. 03 Rec-id pic X(6) value "PAY001". 03 Date pic X(10) value spaces. 03 EEEE-MM-DD Redefines Date. 05 EEEE pic 9999. 05 FILLER pic X. 05 MM pic 99. 05 FILLER pic X. 05 DD pic 99. 03 Amount pic 9(12)V99 comp-3 value zeroes. 03 Currency-code pic XXX value spaces. 03 Description. 05 Desc-line occurs 4 pic X(50) value spaces. 03 Originator. 05 Ident-type-code pic x value spaces. * 'P' Natural person * 'B' Business * 'N' National/Local Gov Agency * 'S' Supranational Agency 05 Ident. 07 Accountnumber pic 9(10) comp-3 value zeroes. 07 N-Name. 09 Familyname pic X(36) value spaces. 09 Title pic X(6) value spaces. 09 Initials pic X(6) value spaces. 09 FILLER pic X(10) value spaces. 07 O-Name redefines N-Name. 09 OrganisationName pic X(48). 09 Contact-nick pic X(10). 07 Address. 09 Street pic X(48) value spaces. 09 Nr pic X(8) value spaces. 09 Postal-code pic X(7) value spaces. 09 Country-code pic XX value spaces. 03 Beneficiary. 05 Ident-type-code pic x value spaces. * 'P' Natural person * 'B' Business * 'N' National/Local Gov Agency * 'S' Supranational Agency 05 Ident. 07 Accountnumber pic 9(10) comp-3 value zeroes. 07 N-Name. 09 Familyname pic X(36) value spaces. 09 Title pic X(6) value spaces. 09 Initials pic X(6) value spaces. 09 FILLER pic X(10) value spaces. 07 O-Name redefines N-Name. 09 OrganisationName pic X(48). 09 Contact-nick pic X(10). 07 Address. 09 Street pic X(48) value spaces. 09 Nr pic X(8) value spaces. 09 Postal-code pic X(7) value spaces. 09 Country-code pic XX value spaces. FD1 open(IN,$datafile); associate($blurk,$COBOLrecord); # Q2; my $total = 0; while(<IN>) { $blurk = $_; #========== this is where the module magic should take effect: # we can now use the COBOL data-item in perl. if ( $Description =~ /(?:salary|gage)/i ) { if ($Beneficiary.ident-type-code ne 'P') { # Q3 print << "WARNING"; # C2 Check this! Salary paid to organisation?: On $Date $Originator.Accountnumber paid $Beneficiary.A +ccountnumber $Currency-code $Amount BENY: $Beneficiary.Organisation +Name $Beneficiary.Contact-nick \"$Description\"\n" WARNING } else { $total{$Currency-code} += $Amount; } } } print "Total salaries / gages in USD $total{"USD"} \n";

So here is the preliminary list of questions:

The example leaves a lot of questions unanswered:

... we can only start at one place at a time. Maybe you could reflect on this, or on your vision of how you would name / use this module.

HTH,

      Danny


In reply to Re: Modules? by mAsterdam
in thread COBOL Layout parsing by broomberg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.