Please help me oh wise monks. My boss(not a professor) needs this code to work for a client, but I can't seem to accomplish his goals the way he wants to. I will post my code and try to explain as best I can. Any help would be appreciated.
$DAT = "/where/my/file/is"; Main: { &Open_File; &Read_File; &Close_File; &Sort_File(@Claim_Number); } sub Sort_File { @T = sort { $a <=> $b || $a cmp $b } @_; foreach $T(@T){ } for ($x = 0; $x < $sz; $x++){ print "$Claim_Number[$T[$x]]\n";#this is the format + of the cod +e statement that my boss wants in the program. He + wants to be able +to replace $Claim_Number with another field. } } sub Read_File { $sz = 0; while(<CLAIMS>) { $x = $_; while(length($x gt 0)) { $_ = substr($x, 0, 434); $x = substr($x, 434); $_ = " ".$_; $Claim_Batch_Number[$sz] = substr($_,1,8); $Claim_Number[$sz] = substr($_,9,6); $Claim_Type[$sz] = substr($_,15,2); $Payment_Direct[$sz] = substr($_,17,2); $Pharmacy_Number[$sz] = substr($_,19,6); $Chain_Number[$sz] = substr($_,25,4); $Pharmacy_Name[$sz] = substr($_,29,30); $Reject_Code_1[$sz] = substr($_,59,4); $Reject_Code_2[$sz] = substr($_,63,4); $RX_Number[$sz] = substr($_,67,8); $RX_Date[$sz] = substr($_,75,8); $Drug_Type_Code[$sz] = substr($_,83,2); $National_Drug_Code[$sz] = substr($_,85,11); $Product_Name[$sz] = substr($_,96,25); $NewRefill_Indicator[$sz] = substr($_,121,1); $Metric_Quantity[$sz] = substr($_,122,8); $Days_Supply[$sz] = substr($_,130,3); $Ingredient_Cost_Billed[$sz] = substr($_,133,8); $Ingredient_Cost_Paid[$sz] = substr($_,141,8); $Dispensing_Fee[$sz] = substr($_,149,8); $Copay[$sz] = substr($_,157,8); $Tax[$sz] = substr($_,165,6); $Total_Amount_Paid[$sz] = substr($_,171,8); $UCR_Amount[$sz] = substr($_,179,8); $Member_Birthdate[$sz] = substr($_,187,8); $Member_Sex[$sz] = substr($_,195,1); $Cardholder_Number[$sz] = substr($_,196,10); $Member_Number[$sz] = substr($_,206,2); $Alternater_Card_Number[$sz]= substr($_,208,20); $Patient_Relationship[$sz] = substr($_,228,2); $Physician_Number[$sz] = substr($_,230,14); $Diagnosis_Code[$sz] = substr($_,244,6); $PDM_System_Number[$sz] = substr($_,250,4); $PDM_Sponsor_Number[$sz] = substr($_,254,8); $PDM_Group_Number[$sz] = substr($_,262,16); $Group_Number[$sz] = substr($_,278,20); $Generic_Code[$sz] = substr($_,298,1); $Mac_Number[$sz] = substr($_,299,2); $Daw_Indicator[$sz] = substr($_,301,1); $Therapeutic_Class_Code[$sz] = substr($_,302,6); $RX_OTC_Code[$sz] = substr($_,308,1); $GPI[$sz] = substr($_,309,14); $Exception_Code[$sz] = substr($_,323,2); $Override_Code[$sz] = substr($_,325,2); $Period_Ending[$sz] = substr($_,327,8); $Paid_Date[$sz] = substr($_,335,8); $Compound_Code[$sz] = substr($_,343,2); $Batch_Date[$sz] = substr($_,345,8); $Claim_Counter[$sz] = substr($_,353,2); $Mail_Order[$sz] = substr($_,355,1); $Benefit_Code[$sz] = substr($_,356,16); $AWP[$sz] = substr($_,372,8); $Claim_Indicator[$sz] = substr($_,380,1); $Drug_Preference_Indicator[$sz] = substr($_,381,1); $Pricing_Indicator[$sz] = substr($_,382,1); $Drug_Manufacturer[$sz] = substr($_,383,10); $Controlled_Substance[$sz] = substr($_,393,5); $Patient_Last_Name[$sz] = substr($_,398,20); $Patient_First_Name[$sz] = substr($_,418,15); $Patient_Middle_Initial[$sz] = substr($_,433,1); $Third_Party_Code[$sz] = substr($_,434,1); $sz++; } }#End While } sub Open_File { open(CLAIMS, $DAT) || die "CANNOT OPEN FILE"; } sub Close_File { close(CLAIMS); } The output comes out as such: 002224 002224 002225 002250 002252 000340 003072 003074 003075 002419 002420 000760 000762 001537 001538 001539 001540 001541 000845 002982 000339 000340 000569 000584 002965 000099 003516 003519 003526 001371 001373 001374 002733 000142 000142 000144 000146 000148 000106 000776 003047 Also contains many bland fields below, but I am not sure if + they wil +l show up on the question.
Please help me. I don't understand his statement and how to achieve it. Any help would be appreciated.
Prince99

too much is never enough...

In reply to Help with arrays/sub procedures by Prince99

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.