UPDATE. Here is my new code:
open(my $in_fh = IO::File->new, "<", $infile) or die "Can't open $infile: $!.\n"; close $in_fh; $chunk =~ s/[\f\r\n]//g; my @statement = split '`', $chunk; my %desc = ( 020 => { type => 'single', names => [ 'account'] }, ##didn't know how else to handle + this 200 => { type => 'single', names => [ 'f1', 'f2', 'f3', 'name', 'street', 'place1', 'place2', 'f8', 'f9', 'f10', 'f11', 'email', ' +f13' ] }, 300 => { type => 'single', names => [ 'name_1']}, 500 => { type => 'multiple', names => ['period_start','loan_id','description','loan_ty +pe','beginning_balance_desc', 'beginning_balance','loan_type_num','loan_branc +h','mail_code','loan_code', 'note_num','late_payment_warn_maxfee']}, 510 => { type => 'single', names => ['transaction_date','posting_date','transaction +_desc','transaction_desc_continued']}, 501 => { type => 'single', names => [ 'rate1', 'rate2' ] }, 530 => { type => 'multiple', names => [ 'transaction_date', 'post_date', 'transaction_ +amount', 'late_fee', 'interest', 'balance_change', 'new_balance', 'transaction_ +desc'] }, 539 => { type => 'single', names => [ 'end_loan']}, 540 => { type => 'single', names => ['deposit_count','deposit_amount']}, 541 => { type => 'single', names => ['withdraw_count', 'withdraw_amount']}, 550 => { type => 'multiple', names => ['interest_desc', 'total_int_YTD','total_fees_YT +D', 'loan_fee','interest_fee' ]}, 551 => { type => 'single', names => ['do_nothing'] }, 250 => { type => 'single', names => ['do_nothing'] }, 334 => { type => 'single', names => ['do_nothing'] }, 330 => { type => 'single', names => ['do_nothing'] }, 333 => { type => 'single', names => ['do_nothing'] }, 343 => { type => 'single', names => ['do_nothing'] }, 344 => { type => 'single', names => ['do_nothing'] }, 340 => { type => 'single', names => ['do_nothing'] }, 412 => { type => 'single', names => ['do_nothing'] }, 570 => { type => 'single', names => ['amount_due','due_date']}, 599 => { type => 'multiple', names => ['period_end_date', 'end_balance_desc','end_bala +nce'] }, 690 => { type => 'single', names => ['additional_info'] }, 701 => { type => 'single', names => ['loan', 'end_balance'] }, ); my %data; #$/ = "`\n"; #would not run through the file if I left this on foreach my $line (@statement) { chomp $line; my @fields = split '~\d\d', $line; next unless length $line; next unless scalar(@fields); my $fieldno = shift @fields; if( exists $desc{$fieldno} ) { if( $desc{$fieldno}{type} eq 'single' ) { @{$data{$fieldno}}{ @{ $desc{$fieldno}{names} } } = @field +s } else { push @{ $data{$fieldno} }, {}; @{ $data{$fieldno}[-1] }{ @{$desc{$fieldno}{names}} } = @f +ields } } else { print "Unknown data $fieldno\n"; } } print Dumper \%data;

In reply to Re: Statement Parsing and Rendering by PerlSufi
in thread Statement Parsing and Rendering by PerlSufi

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.