Ordering array based on arbitrary list.

×

Error message

  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home4/ccollins/public_html/ccollins/includes/common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home4/ccollins/public_html/ccollins/includes/menu.inc).

 

 

<code>

  my $order = [
                'STARTING_BALANCE',
                'NUMBER_OF_DAYS_IN_PERIOD',
                'ENDING_BALANCE',
                'TOTAL_DEPOSITS_LESS_INTEREST',
                'AVERAGE_COLLECTED_BALANCE',
                'TOTAL_WITHDRAWALS_DEBITS',
                'ANNUAL_PERCENTAGE_YIELD',
                'TOTAL_INTEREST',
                ];

foreach (@{$this->{'_statement'}{'ACCOUNTS'}[0]{'ACCOUNT'}}) {

            foreach my $description ( @{$order}  ) {
    
                if (
                defined $_->{'MISC_ACCOUNT_DISCLOSURE'}[0]{'DISCLOSURE'}{$description} 
                and 
                defined $_->{'MISC_ACCOUNT_DISCLOSURE'}[0]{'DISCLOSURE'}{$description}{VALUE} 
                and 
                defined $_->{'MISC_ACCOUNT_DISCLOSURE'}[0]{'DISCLOSURE'}{$description}{NAME} 
                ) {
    
                    my $value = $_->{'MISC_ACCOUNT_DISCLOSURE'}[0]{'DISCLOSURE'}{$description}{VALUE}; 
                    my $descr = $_->{'MISC_ACCOUNT_DISCLOSURE'}[0]{'DISCLOSURE'}{$description}{NAME}; 

                    # stupid but they want it this way
                    #
                    $descr .= $value;

                    push @{$_->{'MISC_DISCLOSURE_ITEMS'}[0]{'ITEM'}}, {
                        TEXT => $descr,
                        VALUE => '',
                        TYPE => $_->{'MISC_DISCLOSURE_ITEMS'}[0]{'TYPE'},
                    };
                }
                else {
                    # if nothing is there just use desription
                    # and $0.00
                    #
                    my $descr = "${description}: \$0.00"; 

                    # remove the seperator
                    #
                    $descr =~ s/_/ /g;

                    # upper case the first letter of each word.
                    # NOTE I really like this one.
                    $descr =~ s/([\w']+)/\u\L$1/g;

                    push @{$_->{'MISC_DISCLOSURE_ITEMS'}[0]{'ITEM'}}, {
                        TEXT => $descr,
                        VALUE => '',
                        TYPE => $_->{'MISC_DISCLOSURE_ITEMS'}[0]{'TYPE'},
                    };
                }
            }

}
    </code>