in reply to How to move hard coded URL in tt files to a Catalyst module file

Pretty sure I follow but as mentioned already, you have not given enough code to know for sure. The module file is going to be a Controller. Named something like, MyApp::Controller::Widget.

In your template you will set the action of the form by using the dynamically generated action->URI of the controller–

<form action="[% c.uri_for_action("/widget/download") %]" method="POST +">

There are several different ways to do what you want. Catalyst is not what I would recommend for learning Perl. Sounds like this is work related so good luck but the learning curve here is quite steep and assumes Perl knowledge.

Replies are listed 'Best First'.
Re^2: How to move hard coded URL in tt files to a Catalyst module file
by alwynpan (Acolyte) on Nov 07, 2016 at 07:28 UTC
    Hi (I'd better not call your screen name), Thank you for your help. But I don't think it gonna work. It is not calling a sub in the Controller, it needs to pass the values in the form to the "download.pl" file. Correct me if I was wrong. You have much more experience in Perl than myself. I just started learning it. Regards, Alwyn

      So far there is no evidence of a script called download.pl in your examples, just the URL. I am skeptical it exists because it would mean you are mixing CGI with Catalyst and using nearly the same names. In your Catalyst application, instead of download.pl there will be a URL path like /app_name/controller_name/download or host:port/controller_name/download if you are running on a high port or using the development server. In those cases, my answer is the right one.

      Catalyst has many parts, including simple deployment, that are extremely difficult for a beginner and it looks like maybe you are reading Catalyst documentation and CGI documentation (perhaps from a webhost?) and trying to mix them. It can be done, it works very badly but it's possible. Your code is wrong for that approach too and I highly discourage it. :( Better to go with vanilla CGI if on a budget host where CGI is the only deployment option.