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

Ok I am looking for honest opinions for what is the best tutorial around for teaching a new perl person how to take information from a webpage form and stick it into a database. I as this because I already have my database template set up and my html setup. I would really appreciate it if someone could point me in the direction of a good tutorial on that subject. Thanks Thargor

Replies are listed 'Best First'.
Re: looking for a good tutorial
by davido (Cardinal) on Feb 23, 2005 at 17:34 UTC

    A little disambiguation is needed:

    Are you asking how to accept data through a web form (CGI) or how to scrape the data from a webpage (spidering / screen scraping)?

    After the data-gathering stage, do you need help learning how to use DBI?

    For the first part, if you're trying to write a CGI script, use the CGI module. Its documentation will give you a start. I also really recommend the second edition of the O'Reilly mouse book: CGI Programming with Perl. You'll get through it in two or three days (maybe faster), and it will go a long way toward getting you going. Ovid's CGI tutorial is also helpful: http://users.easystreet.com/ovid/cgi_course.

    On the other hand, if you are screen scraping and want to dump that into a database, I recommend the WWW::Mechanize module. Read its documentation, and you should be 99% ready to get started.

    For the next step, you need the DBI module, along with a DBD module that targets your particular database. You can try to start by reading the DBI documentation, though I found it almost necessary to read the O'Reilly book "Programming the Perl DBI". I also found my SQL skills lacking, and had to do a fair amount of reading in that regard too.

    Hope this helps...


    Dave

      Sorry if it was a little vague. I am going to need to be able to take 3 variables from a db and display them on the web 2 as drop downs and 1 as just plain text. From the web I will need to be able to take 2 varibles from text that someone has writen and store them along with a selection they made back into the same db. does that clear it up at all?

        It clears things up a bit. You want to follow portion of my previous reply that discusses CGI, and the portion that discusses DBI. Basically the param() method of CGI will allow you to pull info from a web form. And DBI facilitates interfacing with your database in a fairly uniform way. You'll connect to the database, prepare a query, execute the query, and print the results as part of the webpage. Upon receiving information from the webpage, you'll prepare an insert, execute the insert, and probably print a confirmation screen.

        Be sure to do the required reading mentioned above, and feel free to ask any specific questions where you need additional clarification.


        Dave

Re: looking for a good tutorial
by tphyahoo (Vicar) on Feb 23, 2005 at 17:46 UTC
    Thargor, you may find Perl Web/DB Tutorial helpful. But this is with eperl, whereas I'd rather use a more modern/robust framework.

    Now, I have almost the same question, but more specific.

    Can someone point me to a mock application (or open source real application) written with Mason or Embperl, including a framework for managing the db, that's all ready to go, and I can just start tinkering with it to suit my purposes?

    I recently posted the result of banging my head against all the "technology soup" alternatives out there at Survey of Surveys on HTML Templating systems.

    Any help would be greatly appreciated.

    UPDATE: Check out perlmonks' own tutorials which have a good section on "CGI (and related) Programming." I'm headed over there myself.

    Also, I found a bunch of open source mason applications, which I linked to at my updated Survey of Surveys above.

Re: looking for a good tutorial
by perlfan (Parson) on Feb 23, 2005 at 18:18 UTC
      Beginning Perl is an excellent book and has chapters on DBI and CGI programming which should give you the basis you need even if they aren't all that detailed. If you've never done any SQL before, I recommend Introdcution to Structured Query language and obviously the documentation for the specific database that you will be using.

      There is also (of course) a wealth of stuff here on perlmonks ;-)