BMaximus has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Apache::Request to get the params sent from a form. However I hate to keep having to:
# $apr is an Apache::Request object with $apr->parse() # already called. my %params; $params{'text_field'} = $apr->param('text_field'); $params{'text_field2'} = $apr->param('text_field2'); ...
Is there a better way of getting all of the fields into a hash to be given to HTML::FormValidator to mull over? If I  use CGI; along with mod_perl and use the  Vars() subroutine to get what I want. Would there be any side effects from doing so? (i.e. CGI intereferes with Apache::Request so it can't do its job) Could using hash slices do the job without bringing CGI in to it?

Thanks for your enlightenment,
BMaximus

Replies are listed 'Best First'.
Re: Just a wee bit o' mod_perl
by Masem (Monsignor) on Apr 22, 2001 at 06:00 UTC
    Well, you could do something like:
    my %params; foreach my $param ($apr->param) { $params{ $param } = $apr->param( $param ); }
    Though you are still making copies of everything which might seem a bit inefficient...Unfortunately, I don't see a direct way to get at CGI.pm's internal storage of key/value pairs.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
      Thanks Masem. I should have thought of that. I have no idea where my head was.

      Update: CGI.pm allows you get at all parameters through the  Vars() subroutine.
      Used as:  %params = Vars();
      Unfortunatly there is no equivalent in Apache::Request. I think its usefullness warants an addidtion to Apache::Request however I lack the knowlege to be meddling with xs. I'd love to know more about it. I know there is a section on it in the man page for perl.

      BMaximus