Forum Moderators: coopster & phranque

Message Too Old, No Replies

using perl to write up a site.

building websites with perl

         

pxp25

7:07 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



Have anyone use perl to build a site. This is what I mean, use perl to read something/information (ie. product, product description, links..) from a table and then combines that info with html....and then you get your site. It will be all static pages but with perl you can update it (by rewriting the whole site)easily like a dynamic site.

A kind of a static site with all the benefit of SE visibility and the ease of maintainent of a dynamic site.

Anyone try it out yet? I'm looking getting start on this project but I just what to check if anyone else went down this road before....weather this is worth the investigation.

Thanks.

moltar

7:24 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never done this before, but I am not sure why do you want to go that path?

You can have pages dynamically generated from a database and still make them look static.

Havea a look at apache's mod_rewrite [httpd.apache.org] module.

pxp25

8:18 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



molta, what do you mean by them (dynamic page) look static? I very new in this area. What does a mod_rewrite do? I will check out that link you gave me too.

rocknbil

10:06 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you describe is basically a CMS (Content management system) and I can guarantee you this is a good way to pull up a notch in search engines, by writing your script output to hard-coded HTML files. Then you have the best of both worlds, the speed and searchability of dynamic scripting and the html content search engines seem to love.

The only difference is instead of writing to STDOUT you're writing to a file.

There is only one issue you must encompass: the script must be able to write the files somewhere, usually a directory, which means your directory must be world-writable. This is dangerous for various reasons, but if you have no other option - it's the risk you'll have to take.

A very good solution:
Files written by a script are owned by Apache, which means that "everyone" also owns them. But let's say instead of writing the file, you store the content in a database, with or without a site template.

You then have a cron job, which runs as root, that extracts the data from the database and does the actual writing. In this scenario you don't **need** a world-writable directory because root owns it all. The only drawback is that you won't be able to overwrite these files from FTP. You'll just be able to delete them. Which shouldn't be a problem, right? :-)

You can set the cron to run at whatever update intervals you think you'd require, from every five minutes to once a day.

When searching, you simply search the database (lightspeed faster) and point the results to the html files instead of the database. Or what the heck - go ahead and let the results display from the database - the only real reason you need the HTML is for the search engines, and the links to the pages for them to follow. The output should be identical.

You will either have to have SSH access (or God forbid telnet) to the server to create the cron, or buy your admin lots of doughnuts to have him add the cron for you. :-)

Moby_Dim

7:38 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



I've had the same idea about a year ago, and i've created the site based on a simple flat DB with a couple of hundreds of records up to now. ;) Found a hoster who permits to write not only in /cgi-bin/ on this site. Pages are static, but search and other functions (e.g. items comparison) via DB, of course.

petr

8:31 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



a follow up question:
i already have a perl and mysql site at my disposal. in order to load pages they point to .pl files. How do I modify this setup so .html files are generated. Otherwise search engines don't like me so much ;(.

Moby_Dim

11:44 am on Feb 27, 2005 (gmt 0)

10+ Year Member



petr, may be i have not fully understood your problem (English is not my native) but if the question is about the subject, my solution is : the script reads db records and produces .html pages inserting data in a given template. Yes, this's a kind of CMS. When i modify a record in DB, the script refresh the content of the related static page too. Another option is to refresh all the pages on the site.

SeanW

2:48 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



I've done this a few ways both using Template Toolkit.

The first is the simple method using ttree... I have the content pages in separate files, and the script runs the template on each page.

The second came out of a mod_perl engine I had written. All the information is in a database, and the templates generate pages. The script basically spiders the "site", extracting links and generates those pages.

I didn't find the latter any easier than going fully dynamic, since it took several hours to generate the pages (150K in my test). I'm currently rewriting the site in PHP&Smarty and so far I'm able to go fully dynamic (ie pages rendered on the fly) with good performance, largely due to Smarty and PHP's caching abilities.

Sean