in reply to Re: HTML::Template problems
in thread HTML::Template problems

Ahhhh, of course. I'll try it and get back to this.
Thanks,
-dhoss

"and I wonder, when I sing along with you if everything could ever feel this real forever? if anything could ever be this good again? the only thing I'll ever ask of you, you've gotta promise not to stop when I say 'when'", she sang

Replies are listed 'Best First'.
Re: Re: Re: HTML::Template problems
by stonecolddevin (Parson) on Dec 31, 2003 at 23:34 UTC
    Ahh, now instead of 14, it's returning 84.....?

    "and I wonder, when I sing along with you if everything could ever feel this real forever? if anything could ever be this good again? the only thing I'll ever ask of you, you've gotta promise not to stop when I say 'when'", she sang
      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.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)