# loop over all the records in the input file while ( $record = ) { chomp($record); $input_record_count++; for (substr($record, 0, 1) ) { if (/H/) { &H_header($record); } elsif (/C/) { &C_claim($record); } elsif (/P/) { &P_provider($record); } elsif (/D/) { &D_detail($record); } elsif (/M/) { &M_message($record); } } }# end-while #### sub H_header { # unpack the record into local fields # Write the EOB record } sub D_detail { # parse the input record into different individual fields # write the detail service record } sub C_write_claims { foreach (@claim_recs) { # parse the input record into different fields # write the claim record } }