hi,
I have an cgi page named add.cgi where i will get parameters component and command,in my add cgi page and i will also have hash %data.
my add.cgi will be like this, my $component=$query->param('component'); my $ccc_id=$query->param('ccc_id'); my %data = ( ccc_id => $ccc_id, component_name => $component, add => \@tc_add_templ ); my $template = Template->new({ }); $template->process($file,\%data) || die $template->error();
where i will be passing this to template file.tc_add_templ will have data for form field in template ie name and value pairs in my template form elements. in add.tmpl file i will have data like this
<form action="AddTemplateResult.cgi" method="get" bgcolor="#e6ede7"> [% FOREACH element = add %] [% IF element.req == "all" %] <input type="text" name="[%element.name %]" value="[%element.default +%]" size="58">
In AddTemplateResult.cgi i will be getting results and store it in hash
@names=$query->param(); foreach $key (@names) { $val=$query->param("$key"); $hoh{$key}=$val; }
where i will be pasing this hash to anther perl file for processing and add the recpective data in an repositry.
$ref=$tc_ref->add_tc_to_rep(%hoh);
print "$ref\n
If it is added to the repositry sucessfully, i will be getting the message sucessful and print the result.
Here i am using two different cgi file ie add.cgi and AddTemplateResult.cgi.

I need to change that to one cgi file.I need to use only add.cgi.need to use like
<form action="add.cgi" method="get" bgcolor="#e6ede7">
when i am using same cgi file for both passing the values and retriving the result.I am getting error in that.
when i add data to add template ,I need to print the result getting from $ref and need to show the form again to add the data.
For the first time when i hit the cgi page i should get that add template form only.when i add data and submit the data using submit button ,then i should print the result "added sucessfully " and need to show the form again to add the data for futher.
i tried to check
if(ref eq " "){ pass the data to template ; } else { result data code; }
but it is not working in the manner i expected.Any idea how to check these condtions in my code.how to change my code according to problem.
Thanks, srins.

In reply to how to pass the value to template and retrive the result from same cgi file. 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.