I've hit a problem rather early on with use strict;!

I am writing some code mostly to test a module I am writing for this purpose -> To Extend, to Use, to Create - of course, the new code has use strict; at the begining thanks to the good influence of the Monks...

#!/usr/bin/perl use strict; require "incl/common.pl"; require "incl/html.pl"; my $update_time = $dbh->selectrow_array("SELECT NOW()");

The problem I am getting is Global symbol "$dbh" requires explicit package name at eric.pl line 7. The variable $dbh is a database handle from DBD::mysql and it is defined in require "incl/common.pl"; without the my keyword.

I have tried adding my $dbh; before the require statement thinking that I could simply declare the variable before assigning it within common.pl but that still gives Can't call method "selectrow_array" on an undefined value. As should be clear from the filename, common.pl is used by every script on the website so changing the way the database handle is declared and defined is not something I would want to do lightly...although I doubt anything untoward would happen I would rather know.

Any thoughts on how I should proceed?


In reply to Re^2: Backdating strict by Bod
in thread Backdating strict by Bod

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.