hi thanks for your suggestion i tried to pass the hash of hashes i constructed
as $template->process($file,%add) || die $template->error(); for my hash my %add=( hsh1=>{ name=>"name1 ", type =>"text", default=>" ", value=>[" "], entries=>"M" }, hsh2=>{ name=>"name2 ", type=>"dropdown", req=>"prc", default=>" ", value=>["value1","value2","value3"], entries=>" " } ); for your code [% FOREACH element = add.keys %] [% IF add.$element.type == "text" %] <input type="text" name="[% add.$element.name %]" value="[% add.$e +lement.default %]"> [% ELSIF add.$element.type == "dropdown" %] <select name="[% add.$element.name %]"> [% FOREACH option = add.$element.value %] <option value="[% option %]"> [% option %] </option> [% END %] </select> [% END %] <br> [% # put a line break between the form elements %] [% END %]
but i get following error, Content-type: text/html Can't use string ("hsh2") as a HASH ref while "strict refs" in use at /usr/cisco/packages/perl/perl-5.8.6/lib/site_perl/5.8.6/sun4-solaris/Template/Service.pm line 79. i also tried to pass the reference as $template->process($file,\%add) || die $template->error(); but nothing is substituted in the html file.can u help me how to pass my hash to the html file or i need to change the above code.please help me in this regard. Thanks, srins.

In reply to Re^2: how to define html::template for the following hash in perl/cgi by srins
in thread how to define html::template for the following hash in perl/cgi by srins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.