The standard way of handling relational databases in Perl is through the DBI module. DBI acts as the portal into which you pass SQL queries, and out of which you pull the results. DBI then handles the details of interfacing with a database driver, and gives you a fairly simple interface to your database. I recommend reading the DBI documentation thoroughly, paying particular attention to the examples given. Keep an eye open for the portion of the POD that discusses placeholders; they're important. Also, when you think of error handling, think along the same lines as what you already practice with flat files. That is, always check return values to ensure that operations have succeeded.

And then there's SQL. There are as many different flavors of SQL as there are databases, but they all have a lot in common. You can begin to learn the common, basic portion of SQL by visiting this site: http://www.w3schools.com/sql/default.asp. It's a decent online tutorial geared at providing newcomers to SQL with enough of the basics that they can get some work done, while still leaving plenty of room for growth.

Read the DBI documentation, and the SQL tutorial two times, and the light bulb should flick on.

Minor nit to pick. You mentioned converting a PHP website to CGI. CGI isn't Perl. CGI is the "Common Gateway Interface". CGI server-side programs can be written in C, Perl, PHP, and a plethora of other languages. I assume what you mean is converting a PHP based site to a Perl based one.


Dave


In reply to Re: SQL- for starters by davido
in thread SQL- for starters by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.