A few Qs from a beginner

Mick H
  • Mick H

    Mick H - 2004-11-22

    Hi all,
    I am new to Perl AND HTML so I am struggling with some things here that are probably basic to you.
    First I have a small program working where I can pass data to a HTML form successfully, where I am having problems is with returning data.
    For some reason I cannot store global data in my Perl program (is this because it runs anew each time the HTML page returns to the Perl code?) so I have to pass data to the HTML page then return it later. Half the time the data is not returned even though I am sure I am using the correct syntax.
    To save writing a separate <TMPL_VAR Name = "name"> for each bit of data I wish to pass through can I use a hash or reference to a hash here. If I can use a reference will the data be there when the Perl code runs?

    Mick H

    • steve

      steve - 2004-11-29

      There are at least two ways to skin this cat. Two that come immediately to mind are:

      1.  You can use a series of hidden form variables inside a TMPL_LOOP structure like:
         <TMPL_LOOP name="loop">
              <input type=hidden name="<TMPL_VAR name="parm_name">" value="<TMPL_VAR name="parm_value">" >

         and in the code:
          my @parm_list = ();
          while (save_parms){
              my %parm_item = ();
              $parm_item{parm_name} = "name of parameter";
              $parm_item{parm_value} = "paramter value";
              push @parm_list, \%parm_item;


      2. Use the CGI::Session package for serializing state information between executions of your script.

      Good Luck.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks