Just a CGI/DBI thought - doing as you have here by hardcoding the database $serverName, $serverDB, $serverUser, and $serverPass right in your CGI script is dangerous. It's fine for testing or just getting your feet wet with a test CGI application that connects to a database, but one way to make it safer is to *NOT* hardcode the database server and user login info actually in the CGI script - instead, put those variables in their own module(Ex: MY_DB.pm) and put the module *outside* the webserver's document root. By doing that, you prevent someone getting access to that database info if they compromise your webserver.

In your CGI script, put a 'use lib' in there where the value is the directory where MY_DB.pm is located. For example, if you put MY_DB.pm in /path/to/safe_dir/MY_DB.pm, then do this in your CGI script:
use lib '/path/to/safe_dir'; use MY_DB; our $serverName = $MY_DB::serverName; our $serverDB = $MY_DB::serverDB; our $db = "DBI:mysql:$serverDB:$serverName";
Creating modules is pretty easy, and there's good documentation on how - just do
perldoc perl
and look for 'perlmod' - there are several perldoc's describing modules, but I think the one you are interested in is 'perlmodlib' since that one is for how to write and use modules. So, to read the perlmodlib perldoc, just do
perldoc perlmodlib
at a command prompt.

HTH.

In reply to Re: "use strict;" woes by hmerrill
in thread "use strict;" woes by toonski

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.