Why don't you use Data::Dumper to see exactly what @msgs looks like before you return it?
warn Dumper \@msgs;
Now, unless your code looks something like this:
while ( my $thread = $sth->fetchrow_hashref() ){
my (@data) = $thread->{id},
$thread->{name},
$thread->{date},
$thread->{subj},
$thread->{day_rate},
$thread->{msg};
push @msgs, \@data;
}
return @msgs; # although i would likely return \@msgs ...
You will likely run into trouble. But why are you even doing this? Such a waste of effort
and time when a simpler solution is just around the corner:
sub selectMsgFromDb {
my ($self, %params) = @_;
$self->checkRequiredParams(%params);
my $sth = $dbh->prepare( $cfg->{retrieve_from_sql}->{msg} );
$sth->execute;
my $messages = $sth->fetchall_hashref({});
# warn Dumper $messages; # in case you don't believe me ;)
return $messages;
}
Yes, that's really all you need to do, because fetchall_hashref (when passed a
single hash reference) will return a LoH ... which is exactly what an HTML::Template
<tmpl_loop> needs.
|