#!/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() { $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.Accountnumber $Currency-code $Amount BENY: $Beneficiary.OrganisationName $Beneficiary.Contact-nick \"$Description\"\n" WARNING } else { $total{$Currency-code} += $Amount; } } } print "Total salaries / gages in USD $total{"USD"} \n";