sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:

A few more random questions for all the wise monks :)

1) You write a counter script and want it to work off your html page using SSI or something, how can you do this? Someone tried to explain in the CB but it sounded rather difficult but I would imagine it should be a farily simple thing to do. How often do you write a perl script and want it to just be totally perl? Some scripts like counters you have to embed in your html documents somehow otherwise there wouldn't be a point. Can someone lead me to information about this?

2) How can you make a new perl/html file for something a user types in on a form? I'm designing a form which people write and save poems to my site. I want each poem they write to be on their own separate page that the program makes for them.

3) Still working on a poem script I will be saving a lot of information: Poem Title, Poem, Date, Author Name, Category, etc. and hopefully in the future allow them to edit the poems already on the site. Would I be looking at MySQL instead of SDBM or DBM for this?

Thanks for all your help!

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re: SSI/Database questions
by lacertus (Monk) on Mar 27, 2003 at 02:19 UTC
    Using SSI is quite simple, and powerful to boot, since SSI is built into the webserver, it is generally very quick. I have a Perl program that generates website statistics (hits, etc) using the Apache logs. This program takes various arguments, one of which outputs just a simple total/daily hits value. Wit SSI, I can just call this program with the correct argument and have that value placed in the webpage dynamically:
    <!--#exec cmd="program -t daily" -->
    Really simple, I hope I am clear. Answer to your second question can be done in two words: use CGI.

    As for using MYSQL, I generally don't recommend it unless you expect your database to be recieving multiple simultaneous queries - this is where MYSQL shines. It's really a production database. For almost all of my needs, a simple Berkley DBASE works just fine; it is quick and succint, and does not have all the inherent complexities like permissions, etc, that maintaining a MYSQL database has.

    Cheers,
    John

    ------------------------------------
    "There is more in heaven and earth
    than is dreamt of in your philosophy"
      For reasons stated on the apache site (look at the ssi docs here), using the exec option for executing commands is considered dangerous. Heres a reason why:
      <!--#exec cmd="ls" -->
      They recommend that includes are turned on without the exec option available. This is the recommended method:
      <!--#include virtual="/cgi-bin/counter.pl" -->
      You can still pass arguments to your script, though I admit I have only done this using GET style arguments. ie:
      <!--#include virtual="/cgi-bin/counter.pl?offset=1000" -->
      HTH

      Simon
      Ok, I'll try using that snippet to get my counter to work. Do you have to program around SSI (like do you need to know ahead of time how to write it if you plan on using SSI or would a premade counter just assumidly(wd?) work?).

      Use CGI, lol, I kind of love when people say that. You don't know exactly what you're looking for but they send you to a documentation which is like 100 pages in length :P I'll take a look, it's probably something fairly obvious.

      Awesome, looks like MySQL will never have to be used with any of my scripts then. That's a relief cause I've never even been able to open a MySQL database on my server, I'll definately stick with SDBM as that seems to be working great so far.

      Thanks for your help Lacertus!

      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid

        If you're having trouble figuring out how to use CGI from its documentation, start here in the Tutorials section. There are several pages that will help you get started with CGI. The most important parts of CGI are its parsing if incoming data, not the HTML generation stuff. My personal opinion is that generation is better handled with templates but CGI is indispensible for retrieving submitted data. For that, about all you need to know is $query->param("fieldname").

        If you can access a real database, I'd recommend it over SDBM files. I think they're much easier to work with and are certainly more flexible.

        --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
Re: SSI/Database questions
by DigitalKitty (Parson) on Mar 27, 2003 at 03:19 UTC
    Hi sulfericacid.

    I thought these SSI tutorials might help you. The other monks are quite correct. 'Server Side Includes' are very powerful indeed. The more varied your skill set ( perl, cgi, ssi, etc. ), the better.

    SSI tutorial

    Another SSI tutorial

    Hope these help,
    -Katie.