hesco has asked for the wisdom of the Perl Monks concerning the following question:

I'm not quite sure what is unblessed about what reference in my query below. Any ideas? -- Hugh

My code throws these errors:

$dsn = DBI:mysql(RaiseError => 1):host=localhost.localdomain;database= +testdb $dbh = HASH(0x9d44a24) Can't call method "prepare" on unblessed reference at ./cache-pages.pl + line 28.
and reads like this:
$dbh = ed_connect($conf{'dbversion'}, $conf{'dbhost'}, $conf{'dbname'} +, $conf{'dbuser'}, $conf{'dbpass'}); print "\$dbh = $dbh \n"; $sql = "SELECT summary FROM mod_article"; $sth = $dbh->prepare($sql); $sth->execute(); while ($node = $sth->fetchrow_array()) { $ed = $node; $ed =~ s/^.*(\d{5}).*$/$1/; print $ed; } exit; 1; sub ed_connect { my($db_version,$host_name,$db_name,$db_user,$db_pass)=@_; # my $dsn = "DBI:mysql:host=$host_name;database=$db_name"; my $dsn = "DBI:$db_version(RaiseError => 1):host=$host_name;databas +e=$db_name"; print "\$dsn = $dsn \n"; return (DBI->connect($dsn,$db_user,$db_pass), {PrintError => 1, RaiseError => 1}); }

Replies are listed 'Best First'.
Re: monk seeking blessing?
by demerphq (Chancellor) on Jan 21, 2006 at 21:42 UTC

    return (DBI->connect($dsn,$db_user,$db_pass), {PrintError => 1, RaiseError => 1});

    is wrong. It should I think read

    return DBI->connect($dsn,$db_user,$db_pass, {PrintError => 1, RaiseError => 1});
    ---
    $world=~s/war/peace/g

      Yes, thank you. That did the trick.

      love the global string substitution in your signature.

      -- Hugh