Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how do I work perl scripts into HTML?
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
greenapplesodaex




PostPosted: 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
Sponsor
sponsor
wtd




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: