adding key to DB object

From: Brandon Metcalf (bmetcalf_at_nortel.com)
Date: 03/29/05


Date: Tue, 29 Mar 2005 11:39:07 -0600 (CST)
To: dbi-users@perl.org

Can someone explain why I can't do the following:

  $ cat uu
  #!/usr/bin/perl -l

  use strict;
  use warnings;

  use DBI;

  my $dbname = 'foo';
  my $host = 'myhost';

  my $dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$host", '', '');
  print $dbh;
  $dbh->{commitflag} = 1;
  print "commitflag is $dbh->{commitflag}";
  __END__
  $ ./uu
  DBI::db=HASH(0x82f8958)
  Use of uninitialized value in concatenation (.) or string at ./uu line 14.
  commitflag is

$dbh is nothing but a reference to a hash and I can do the following:

  $ cat kk
  #!/bin/perl -l

  use strict;
  use warnings;

  my $hr = { 'test' => 1 };
  print $hr;
  $hr->{flag} = 1;
  print $hr->{flag};
  __END__
  $ ./kk
  HASH(0x814cbb8)
  1

-- 
Brandon


Relevant Pages