sub get_account { my $acct_num = pop; my $ar = $dbh->selectall_arrayref( 'SELECT * FROM account WHERE account_number = ?', { Slice => {} }, $acct_num ); my ($account) = @$ar; $account->{transactions} = \{get_transactions($account->{transactions_id})}; $account->{owners} = get_owners( $account->{customers_id} ); return $account; } sub get_transactions { my $transactions_id = shift; my $sql = <<'EOSQL'; SELECT s.transaction_date, type.name, s.amount, s.new_balance FROM transactions t JOIN single_transaction s ON t.single_transaction_id = s.id JOIN transaction_type type ON s.transaction_type_id = type.id WHERE t.id = ? EOSQL my $ar = $dbh->selectall_arrayref( $sql, undef, $transactions_id ); my @lines; my $count = 1; my %transac; for ( @$ar ) { my ($key, $type, $amount, $new_balance) = @$_; $key =~ /\A(\d{4})-(\d{2})-(\d{2})/; my $date = "$3\/$2\/$1"; my @line = ($count, $date, $type, $amount, $new_balance); $transac{$key} = \@line; $count++; } return \%transac; } #### my $template = HTML::Template->new( filename => 'atm_choose.tmpl', die_on_bad_params => 0 ); my $account_number = param( 'account_number' ); my $account = MyDB->get_account( $account_number ); $template->param( %$account ); print header, $template->output;