On 11/10/05, Senthil Nathan <rsennat@gmail.com> wrote:
> Hi Roger,
>
> Thanks. That works now.
>
> This is how I did it,
>           foreach $instance(@diagnosis)
>           {
>                 my %row = (
>                   line => $instance
>                 );
>                 push(@diag, \%row);
>           }
>           $template->param(dign_loop => \@diag);
>
> So, Can't we directly pass an array to the template?????

Well, you do pass an array (ref) directly to the template.
But, as you have shown above, it must be an array of
hashes.  You could shorten your code a little:

$template->param( dign_loop =>
    [ map { line => $_ }, @diagnosis ] );

The problem with accepting an array of strings is you
must somehow indicate in the template where each string
should be placed.  Your expectation seemed to be to use
the name of the array as the placeholder.  There are a
number of reasons why that approach is not a good one
(IMO), but the simplest argument is that the method
doesn't know the name of the array.

... long story short, make each array element a hash,
use the hash key(s) as your placeholder(s), and you're set.

Regards,

Brad