Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Starting with Perl

by bjg (Acolyte)
on Jul 26, 2005 at 09:08 UTC ( [id://478097]=note: print w/replies, xml ) Need Help??


in reply to Starting with Perl

Thanks guys for the info.

I have been reading some of the tutorials for the last two days, so I know where to go to start learning Perl, but just needed advice on what to do re: templates.

I've looked at TT and Mason and they basically look like diff languages. I really want to use Perl though, so as to learn it better. See I do a lot more web projects than admin scripts, so want to actually use Perl, not some template.

But thanks I got the info I needed. Will give require a go and go from there. I probably should have read http://perldoc.perl.org/functions/require.html properly, as it looked like it doesn't do what I wanted at first glance.

Replies are listed 'Best First'.
Re^2: Starting with Perl
by bradcathey (Prior) on Jul 26, 2005 at 11:24 UTC

    Interesting point and it might be good to know how to include HTML within your Perl, but know there are 3 ways to do that:

    1. print statements (messy for a big HTML page)
    2. here docs
    3. CGI (lots of little 'codes' to learn)

    However, if you are going to be doing any extensive web stuff, don't discount the templating route too quickly. I use HTML::Template exclusively and love it. It's really *not* like learning a whole new language (coding conventions aren't that extensive and are pretty easy to learn—feels like HTML), and most importantly, you keep HTML and Perl (or any executable server side coding separate. This is expecially important if you are working with non-programming web page designers (like I do every day).

    In any case you will want to add CGI to your ammo belt. Take a look at a short course by the Monastery's very own Ovid.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      I would also recommend HTML::Template. To add a bit more check out some framework for CGI applications. Such as CGI::Application.

      HTML::Template + CGI::Application work well together - and there are many resources about both (CGI::App even has it's own Wiki with tutorials, articles FAQ ...etc)

      It wont get you too far away from "dirty Perl" - but it's a much better and cleaner approach. Not to mention it's much faster way to write code ... Actually I'm running whole web sites on it - and even under plain CGI it works reasonably well.

      Template toolkit might be another good option - but somehow I got the same feeling - it's simply not it. It's not Perl, it's not HTML. Maybe I'm wrong (probably I am since many people say it's good) as I still haven't had time to read book about it ...

Re^2: Starting with Perl
by Jaap (Curate) on Jul 26, 2005 at 09:45 UTC
    I don't think may people here will agree, but i recommend for your first web-app you don't use a templating system and just print HTML statements wherever you need them. This has 2 advantages:
    • You really see what happens right in the code
    • It gets so dirty so quickly that next time you'll want to use a templating system
    As for the inclusion of another perl file:
    You can use eval but the better way would be to create a perl module (.pm file) that you can then use.

      I second that idea. Do it without a templating system to get a strong viceral sense of why they're such a great thing. Then translate your project into whatever template system you choose. Both experiences, the raw creation and the translation from one system to another, will contribute to your mental toolbox.

      Be Appropriate && Follow Your Curiosity
Re^2: Starting with Perl
by samizdat (Vicar) on Jul 26, 2005 at 12:24 UTC
    I agree that we'll all disagree on templating systems. :) I use HTML::Embperl (I'm using 1.3.6) extensively and find it very useful, particularly in regards to automatically building tables and forms from a database. It did take a while to get it set up because it really likes mod_perl and because you will want to determine which session management system to add to your Apache.

    I used to do a lot of PHP, but not any more. There are too many Perl-specific modules out there that are goldarned indispensible when you're doing anything more than just print <blah>ing a web page.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://478097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found