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

I am starting to develop pages with HTML::Mason. How can I get the parameters from the Query String such as: user=nighthawk&knowledge=0&... Where I would want to get, ultimately, $user and $knowledge to use in the HTML? My first thought was to use CGI::Request, but that seems like overkill. It seems as though there must be something built into Mason that handles this. -- Nighthawk

Replies are listed 'Best First'.
Re: HTML::Mason - Getting CGI Parameters
by btrott (Parson) on Apr 05, 2000 at 02:09 UTC
    It does have its own built-in method, I think. From skimming the tutorials at PerlMonth, it looks like you just declare the argument in an %args section, then just use the variables as $user and $knowledge. The variables are created as my variables lexical to the component.

    So:

    <%args> $user $knowledge </%args> User: <% $user %> Knowledge: <% knowledge %>
    Have you looked at the tutorials? They might be helpful:

    Part 1
    Part 2

      Thanks! This was perfect. Additionally, you need to preset the values of these args in case they are not supplied: <%args> $user => 'nighthawk' $knowledge => -1 </%args> The PerlMonth tutorials are very helpful. -- Nighthawk
Re: HTML::Mason - Getting CGI Parameters
by Lexicon (Chaplain) on Dec 26, 2000 at 11:57 UTC
    Part 3 of the tutorial has finally been put up as well.

    Perl Month
    Part 1
    Part 2
    Part 3

    The're a really great get-ya-going fast kinda tutorial.

Re: HTML::Mason - Getting CGI Parameters
by chromatic (Archbishop) on Apr 05, 2000 at 02:06 UTC
    HTML::Mason::Component provides the http_input() method, if you're running under Apache and mod_perl. It returns the query string (under the GET method) or the content block (under POST).

    If that doesn't apply... the HTML::Mason FAQ might shed some light.