in reply to I really need help with perl data structures and HTML::Template

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