Hey man,
I'd say I'm in the same boat as you. I've done some web development in PHP, and decided to at least try Perl out. Soon enough, I liked it a whole lot better.
As previously mentioned, your first step is to learn the basics of Perl. A lot of it is similar to PHP, but there's also a lot that
just makes more sense. Head over to this
free library to read up. It will stall whatever web projects you have going, but I think without taking time to learn, your code will essentially be PHP code written in Perl.
Regardless, the
biggest difference between PHP and Perl is that PHP was made for the web. And so, PHP will automatically handle a lot of things for you, which you need to manually do in Perl. For example, consider headers. At the end of the script, PHP will automatically send your header, unless you specified that a different header be sent. Also, any cookies set via
setcookie will be sent with that header. In Perl, you have to do that yourself: It's not hard, but it tripped me up, especially before I realized that any and all cookies needed to be sent
with the header.
If you haven't already started to try to use a templating system, I'd strongly suggest that. It may not make much sense at first... but try using it for a bit, and then compare your results to what you had before. You will get much cleaner results, and even if you
aren't hiring some HTML kiddie who doens't know Perl, this will help you out. It's much much easier to trouble shoot your HTML / CSS without your Perl getting in the way, and vice versa.
So, as a
direct answer to your question: It's possible, both using CGI and
print'ing your HTML, and with something like
HTML::Mason. However, try out the
Template Toolkit. Using
this tutorial, I literally learned the basics and made a simple dynamic page in about ninety seconds. Still, to each his own: Do what you're comfortable with, and if it's not for you, know that there are other options out there. Kind of like moving to Perl from PHP ;-).
Best of luck!
Salazar
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.