Bill Stephenson wrote:
> Take a look at the example scripts and docs...
>
> http://search.cpan.org/src/LDS/CGI.pm-3.29/examples/index.html
>
> http://search.cpan.org/src/LDS/CGI.pm-3.29/cgi_docs.html
>
> I'm pretty sure you'll find the syntax you need in those documents.
>
> Kindest Regards,
>
> --
> Bill Stephenson
I actually have the book as well ('Official Guide to Programming with
CGI.pm') and have practically torn it apart trying to find a way to do
what I want. I've tracked down and read a number of articles and forum
postings as well.
I have a feeling that a hash can't be passed this way. Arrays and
strings are no problem, but I believe the CGI protocol does not allow
passing complex data structures like arrays of hashes, or hashes of hashes.
>
>
> On Apr 29, 2007, at 2:02 PM, [email protected] wrote:
>
>> I have several instances where I would like to pass a hash (or a hash
>> reference) in a hidden form field to a subroutine within the same
>> script upon submitting the form.
>>
>> So far all my attempts have failed. I'm not even sure if this is
>> possible. I know about passing named parameters and references but
>> that only seems to work if the subroutine is called directly, not due
>> to a form submission. Does anyone know if this is even possible, and
>> if so, some direction I can take?
>>
>> #! /usr/bin/perl
>> BEGIN
>> {
>> open (STDERR,">>$0-err.txt");
>> print STDERR "\n",scalar localtime,"\n";
>> }
>>
>> use strict;
>> use warnings;
>> use CGI ':standard';
>>
>> my %Categories =(
>> 1 => "Exterior",
>> 2 => "Interior",
>> 3 => "Audio",
>> 4 => "Vehicles",
>> 5 => "Packages"
>> );
>> my $form_url= url();
>>
>> print "Content-type: text/html\n\n";
>>
>> my $MODE=param('Mode');
>> {
>> no strict;
>> $MODE="PageOne" unless $MODE; # default sub to execute
>> &$MODE; # else execute this
>> }
>> ##############################################
>> sub PageOne
>> {
>> print "<html><body>";
>>
>> foreach my $k ( sort keys %Categories)
>> {
>> print "[$k] => $Categories{$k}<br>";
>> }
>>
>> print <<EndHTML;
>> <form method="post" action="$form_url">
>> <input type="hidden" name="Categories" value="%Categories">
>> <input type="hidden" name="Mode" value="ReadCat">
>> <input type="submit">
>> </form>
>> </body>
>> </html>
>> EndHTML
>> }
>> ##################################################
>> sub ReadCat
>> {
>> my %Cats = param('Categories');
>> print "<html><body>";
>> foreach my $k (keys %Cats)
>> {
>> print "[$k] => $Cats{$k}<br>\n";
>> }
>> print "</body></html>\n";
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.