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

Hi, I have a question regarding a translation that I'm trying to do from php to perl.. I'm currently using catalyst to create a page, the php file I'm translating's receiving at the beggining of the file a parameter from a javascript method, this is done in php as follows:

<?php> $typing = $_GET['field']; <?>

Also, this php page is mixed with html code, does that mean that I have to use tt2 here?, I understand that I may have to use CGI (request method), thing is.. that I don't know if the CGI object can be linked to a page or if it does it automatically.. Thanks in advance

Replies are listed 'Best First'.
Re: translating php to perl
by jethro (Monsignor) on Dec 17, 2010 at 13:58 UTC

    Check out http://php.net/manual/en/reserved.variables.get.php:

    An associative array of variables passed to the current script via the URL parameters.
    So this is the same data that should be found in catalyst in $c->request->query_parameters->{field}; (catalyst experts please correct me if I'm wrong here).

    And yes, the corresponding method to mix code and html with perl is templating, any templating modul will work.

Re: translating php to perl
by Arunbear (Prior) on Dec 17, 2010 at 17:22 UTC

    You can use any template system supported by catalyst, see Catalyst::View for a list of them (though TT2 is perhaps the most popular choice).

    The man page for Catalyst::View::TT shows how to access query parameters from the templates e.g.
    The field is [% Catalyst.req.field %]