Hello all:

I'm working on an application which has outgrown its previous configuration arrangement. I'm now getting the following error, on the following line, which is calling the subroutine reproduced below.

How can I make this error go away and this script give me my database connection from the new configuration scheme? Why does it wait till the db_name to choke, while allowing the db_host_name to pass through without complaint?

-- Hugh

Software error:

Can't use string ("databasename ") as a HASH ref while "strict refs" in use at /usr/lib/cgi-bin/bc/supporters.cgi line 265.

(Yes, I see that I still need to strip that trailing space. That is a different issue, I think).

line 265 reads:

my $dbh = vol::connect_new($config{'db'}{qw(db_host_name db_name db_us +er db_pw)});
that subroutine reads:

sub connect_new { my($host,$db,$user,$pw) = @_; # my $host = "$config{'db'}{'db_host_name'}"; # my $db = "$config{'db'}{'db_name'}"; # my $user = "$config{'db'}{'db_user'}"; # my $pw = "$config{'db'}{'db_pw'}"; my $dsn = "DBI:mysql:host=$host;database=$db"; return (DBI->connect($dsn,$user,$pw, {PrintError => 0, RaiseError => 1})); }

In reply to Can't use string ("") as a HASH ref while "strict refs" by hesco

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.