Thank you all for your help. The reason why I'm putting a bit of code into the SUBS package is that I've got about 5 different CGI scripts which get information out of SUBS - it saves me repeating alot of code. My solution was as follows. In SUBS:
package SUBS; use Exporter; @ISA = qw(Exporter); @EXPORT = qw ($log $site $base $dbh); use vars qw ($log $site $base $dbh); sub connectdb() { #Open the Oracle database: my($dbline,@dbinfo); if (!defined(open(DBINFO, "$base/dbinfo"))) { die "Can't open dbinfo.\n"; } while(defined($dbline = <DBINFO>)) { chomp($dbline); push @dbinfo, $dbline; } close(DBINFO); $dbh = DBI->connect($dbinfo[0],$dbinfo[1], $dbinfo[2],$dbinfo[3], { RaiseError => 1, AutoCommit => 1} ); $dbh->trace(2,"$log"); }
While in db.cgi:
package SUBS; use SUBS; . . . &connect_db();
The main difference betwee this example and my original post was that I am now using use SUBS as opposed to require SUBS as before. I'm also using 'use var'. SUBS also now exports only those variables used by db.cgi in the @EXPORT array. Again, thanks for all your suggestions.
Stacy.

In reply to Re: Re: using modules by maderman
in thread using modules by maderman

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.