in reply to Re^2: Perl/Cgi: Passing Hash Data Within
in thread Perl/Cgi: Passing Hash Data Within

Yes,

You can build your cgi page looping through your hash keys and creating a dynamic page. Then re-assign the values and pass them in as hidden parameters.

As long as you import your parameters into each form tag and then submit them out you can pass parameters for ever.

Here is somewhat of an in depth example but I am sure you can see how I have passed them in the code.

#!/usr/bin/perl -wT use strict; use CGI qw(:standard); my $var1 = param('one'); my $var2 = param('two'); my $var3 = param('three'); my $var4 = param('four'); my $thisapp = "test_pass"; my %stuff = ( Name => "Elijah", Age => "74", Sex => "Female", Location => "/home"); if (!$var1 && !$var2 && !$var3 && !$var4) { new(); }elsif (!$var1 || !$var2 || !$var3 || !$var4) { missing(); }else{ success(); } sub new { print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<NEW; <html> <head><title>NEW</title></head> <body> <form name="pass" method="post" action="$thisapp"> NEW for my $key ( keys %stuff ) { my $value = $stuff{$key}; print "<p>Name:&nbsp;<input type=\"text\" name=\"one\" value=$va +lue maxlength=\"30\" style=\"width: 180px\"></p>" if ($key eq "Name") +; print "<p>Age:&nbsp;<input type=\"text\" name=\"two\" value=$val +ue maxlength=\"30\" style=\"width: 180px\"></p>" if ($key eq "Age"); print "<p>Sex:&nbsp;<input type=\"text\" name=\"three\" value=$v +alue maxlength=\"30\" style=\"width: 180px\"></p>" if ($key eq "Sex") +; print "<p>Location:&nbsp;<input type=\"text\" name=\"four\" valu +e=$value maxlength=\"30\" style=\"width: 180px\"></p>" if ($key eq "L +ocation"); } print <<NEW; <p><input type="submit" value="Pass Data" style="width: 150px"></p> </form> </body> </html> NEW } sub missing { print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<MISSING; <html> <head><title>MISSING</title></head> <body> <p>You are missing an input value!</p> </body> </html> MISSING } sub success { print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<SUCCESS; <html> <head><title>SUCCESS</title></head> <body> <form name="pass" method="post" action="$thisapp"> <input type="hidden" value=$var1 name="one"> <input type="hidden" value=$var2 name="two"> <input type="hidden" value=$var3 name="three"> <input type="hidden" value=$var4 name="four"> <p>Data passed was:</p> <p>Name: $var1</p> <p>Age: $var2</p> <p>Sex: $var3</p> <p>Location: $var4</p> <p><input type="submit" value="Pass Data" style="width: 150px"></p> </form> </body> </html> SUCCESS }
Here I assign the values from the hash at first but once loaded I pass them using hidden parameters. You can see a working example of this script here.

Hope this is of some use to you.