$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 code 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() { $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 will show up on the question.