how do I work perl scripts into HTML?
Author |
Message |
greenapplesodaex

|
Posted: Mon May 08, 2006 3:09 pm Post subject: how do I work perl scripts into HTML? |
|
|
I've been learning perl language for a while. out of all the tutorials i found, they all just give you a chunck of code and tell you what it does, but non of them really teaches you how to embed the script into html.
Anyone has any good tutorials for that?
Thanx in advance. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
wtd
|
Posted: Mon May 08, 2006 3:17 pm Post subject: (No subject) |
|
|
To accomplish this, you run a Perl program on the webserver. The Perl program outputs HTML which is sent to the brower.
The simplest way to accomplish this is to just use Perl's "print" to output the HTTP header and HTML. Other facilities do exist to make creation of HTML easier, though. I am especially fond of Template Toolkit. |
|
|
|
|
 |
rdrake

|
Posted: Mon May 08, 2006 8:10 pm Post subject: (No subject) |
|
|
Like wtd said, the simplest way would be to have your scripts output the html and header information themselves. You'll need to configure your web server (look in the docs) in order to parse the pl files. Alternatively, I believe you can mark the scripts +x and add a shebang line to the top pointing to your perl install. They'll typically run as CGI scripts.
Your basic perl script may look like this:
code: | #!/usr/bin/env perl -w
print "Content-type: text/html"
print "..." | Where "..." is your html code.
But yes, templating toolkits and such do simplify things drastically, meaning you only have to worry about the behaviour of your scripts, not the look of what they produce.
Oh yes, if you're using apache, you might want to check out mod_perl. Much faster script execution that way. |
|
|
|
|
 |
|
|