Front page | perl.beginners |
Postings from May 2012
Re: Template toolkit issue [SOLVED]
From: Octavian Rasnita
May 3, 2012 12:47
Re: Template toolkit issue [SOLVED]
Message ID: 11C18D8AFCA34B8A8236BD95D49DDEE3@octavianf303f0
From: "Mark Haney" <email@example.com>
Subject: Re: Template toolkit issue [SOLVED]
> One, in the original post of mine about PHP and perl interaction I was
> told to try the template-toolkit, mason, dancer, catalyst, etc. I looked
> into each one and decided on the toolkit. At no time did anyone mention
> that it's 'uncommon' to build a website with just the toolkit.
"With just the toolkit" wouldn't have been very clear because it would have
implied that you either parse the form parameters manually which is not
recommended or that you don't want to create a web app.
If you want to create a web app, you either should use CGI.pm, or a more
simple module from CPAN that can parse the form parameters, or mod_perl's
interface, or a web framework...
> Information like that is extremely useful to those who are getting their
> feet wet and would like the experience and wisdom of those in the know. It
> would have been even more helpful had that tidbit been mentioned back when
> replying to my first post.
> Two, it appears I have hit an impasse on using the toolkit. Ubuntu
> doesn't offer the Apache::Template module in a .deb package and I would
> prefer not to use CPAN to keep from potentially blowing the other modules
> up. Mason's perl modules are available, but I'm not quite sure what my
> next step will be at this point.
Apache::Template is not Template-Toolkit. It is the mod_perl interface to
And it is not recommended to use Perl which is installed by your Linux
It is better to install your own Perl and let the system Perl as it is. For
doing this, the most simple way would be to use Perlbrew:
And it is also recommended to use local::lib:
Then you can install any Perl module you like, where you like.
> I'd /really/ like to find a good stable templating
> system/method/package/whatever IN PERL that I can get this web app up and
> running without too much trouble.
> I'm afraid I've spent just about too much time researching this because
> I've wanted to keep everything in perl and simply didn't know enough to
> make an informed decision.
> So, it's back to the drawing board, I think.
As I already told you, Perl is not recommended for a program similar to a
PHP program that you can do as a beginner after reading some answers from a
mailing lists in 2 days, because the program will work, but it won't be one
that uses a recommended way. And the recommended way today is very seldom to
Other ways may be more complicated, but here are a few "complicated" ways:
Use Catalyst framework
Install Catalyst::Runtime - the modules needed to run your Catalyst app, and
Catalyst::Devel - the modules you need to develop a Catalyst app:
cpan> install Catalyst::Runtime Catalyst::Devel
Create the first Catalyst app and run it:
Then access it at:
Then you can read its documentation at:
And start adding code to it.
Note that most examples will use Template-Toolkit and the ORM DBIx::Class
but you don't need to use any orm and any templating system if you don't
Then create a psgi script for this app if you want to use the PSGI
my $app = BRK->apply_default_middlewares( BRK->psgi_app );
Then you can run your app with Starman which is a very fast web server,
using a command like:
starman --listen :5000 --workers 5 --max-requests 1000 --pid
/srv/log/site.pid --access-log /srv/log/access.log --error-log
/srv/log/error.log --daemonize myapp.psgi
To read about the advantages of using PSGI would need you to read much more
documentation on CPAN...
With Catalyst you don't need to create the Template-Toolkit instance because
it gets created automaticly, you don't even need to specify the names of the
templates (unless you want something else than the default).
Apache is not the recommended web server because it consumes a lot of
resources and it has very many features, but most of them won't be useful
for you anyway, and other servers like nginx/lighttpd or Starman are faster
and require fewer resources.
But what you need depends on more things you haven't told us about, because
in some cases CGI.pm may be enough.