in reply to Lost Values from parse_form Sub

print $q->header,start_html," @names $action $time $date filet = $file +t",end_html;
You have 4 undeclared variables, don't you mean to use those as hash keys instead?
print $q->header,start_html, $sr->{action}, $sr->{time}; # etc.
But, why are you even copying from $q->param?

UPDATE:
Sometimes i use grep to grab out things like submit buttons, say that i have a form with multiple submits whose names are prefaced with 'go_':

my @choice = grep /go_/, $q->param;
No need to copy the contents of CGI::param() to an array, loop through it copying each value to hash ... grep!

UPDATE UPDATE: and if you are saying "hey, that only gets the names, what about the values?"

my %choice = map {$_ => $q->param($_)} grep /go_/, $q->param();

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Lost Values from parse_form Sub
by jerrygarciuh (Curate) on Mar 10, 2002 at 17:43 UTC
    OK I appreciate the simplicity of the importing of the param info into the hash, and I see now that I was receiving the values but not accessing them correctly. This leads me to a couple of questions:
    • Was I making an anonymous hash with my sub? That would explain why the variables were undef, because they were really vars, just hash keys right?
    • So how would I add a line(s) so that the sub would automatically translate param( 'this' ) into $this and assign the value it received? I guess I should use map on the hash keys and values somehow? I realize the 'right' way is probably just to use the hash as it is, but I really like having $foo = "bar" to work with.
    Any help greatly appreciated.
    TIA
    jg
    _____________________________________________________
    It's not my tree.
      First question: no, the hash was not anonymous, you named it $sr - it is, however, a hash reference.

      Second question: don't do that!!

      The right way is indeed to use a hash, but here is the wrong way just for you: (and notice no use strict)

      use CGI; # don't use ':standard' unless you don't want OO CGI.pm my $q = CGI->new(); $$_ = $q->param($_) for $q->param(); print "$foo and $bar\n";
      This works when run like so:
      $ perl foo.cgi "foo=baz&bar=qux"
      baz and qux
      
      But using symbolic references is bad practice. Please, for your sanity down the road, stick with hashes to store 'dynamic' variable names.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)