I researched online and found some interesting Perl modules / frameworks, such as HTML: Mason, HTML :: Embperl or the Catalyst MVC framework, etc. that can allow me to embed Perl inside html, like PHP code inside HTML.
However, my Perl project must be uploaded to a uni server, where only limited privileges and resources are provided.
For example, Apache version 1.3.3 and Perl version 5.8.0 (below Catalyst requirements)
I used a script to check all installed Perl modules, only those names contain the word "html":
HTML::HeadParser 2.17 HTML::Entities 1.23 HTML::Filter 2.09 HTML::LinkExtor 1.31 HTML::Parser 3.26 HTML::PullParser 2.06 HTML::TokeParser 2.24 HTML::Tagset 3.03 HTML::Form 0.03
I'm afraid none of them can let me embed Perl directly in html.
I know that I can use a simple print statement along with "heredoc" to print everything on an html page inside Perl / CGI, but I think this violates the MVC design paradigm and is less flexible and harder to develop, mainly because now business logic mixed up with html markup.
My current solution is to use jQuery to run AJAX requests to load html into specific tags from the client side. Thus, in this case, Perl is used only to provide access to server data, manage the relevant data, and provide JSON responses to AJAX requests.
I wonder if there is a better way to do this? I can hardly change the status of the server, and I donβt think that the system administrator will be so generous as to install any other Perl modules.
Updated information:
The main reason for embedding Perl in html is that I am very new to CGI programming, and since I am more familiar with PHP and jQuery, I would like to know if there is a suitable way to embed Perl directly in html, so I can quickly complete the client part and focus on server side.
Say something like this:
<div id='user_status'>Your last visit was :[% getLastVisitDateTime($userId)%]</div>
Please accept my little knowledge of Perl / CGI and thank you very much for your help in advance.
Updated 2: Following the instructions on the Template Toolkit website, I installed this module on my MacBook Pro, but unfortunately I canβt install it on a uni server due to permission:
Warning: You do not have permissions to install into /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi at /usr/lib/perl5/5.8.0/ExtUtils/Install.pm line 84. mkdir /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread- multi/auto/Template: Permission denied at /usr/lib/perl5/ 5.8.0/ExtUtils/Install.pm line 137 make: *** [pure_site_install] Error 255
So, unfortunately, I'm now looking for other ways ...
Well, it looks like HTML :: Mason cannot be installed for the same reason. Therefore, I am afraid that I should find a solution .pm only so that I do not need to install anything in the perl uni server environment ...