This is a repost or my reply since the original post
was double-posted and
the one that my reply was originally attached to
was cleaned up :)
Well, I see a few problems here. First off when you're doing
push @domains,$aaa; you're not pushing
the value of the hash %aaa on to @domsons, you are pushing
the undefined scalar $aaa onto @domains.
use strict
would have helped you pick this up. Try this instead:
while(my $row=$sth->fetchrow_hashref()){
push @domains, $row;
}
then you can iterate through @domains like this. And you test print
statment will work (formated slightly different).
print "$domains[0]->{subdomain}\n";
my $d;
foreach $d(@domains){
print "$d->{subdomain}\n";
}
Then calling HTML::Template with this code:
my $template=HTML::Template->new(filename=>'test.tmpl');
$template->param(DOMAINS => \@domains);
print $template->output();
and this template
<TMPL_LOOP NAME=DOMAINS>
Subdomain: <TMPL_VAR NAME=SUBDOMAIN>
</TMPL_LOOP>
produces the desired result (at least off of my DB and PERL).
Most of the problems you are having seem to be related
to perl datastructures and references. When you get a chance
you should read the perldsc and perlref
documents that come with perl. They should put you on
the right track with datastructures and references
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.