polettix has asked for the wisdom of the Perl Monks concerning the following question:
Update: I happened to finish my CPAN::Mini donwload and reinstalling DBI. It all works good now, thanks to all and sorry for not trying the reinstall before boring you!Wisest Monks,
I've having a hard time with the following code, which accuses me of an Attempt to free unreferenced scalar: SV 0x81bf1f8.
which yields:#!/usr/bin/perl use strict; use warnings; use DBI; ###################################################################### +## package Category; sub new { bless {}, shift; } sub load_fromdb { my ($self, $dbh) = @_; my $query = "SELECT * FROM Category WHERE tag = 'tag'"; ########## -1- ########## print "load_fromdb: got " . $dbh->selectall_hashref($query, 'id') . "\n"; } sub save_todb { my ($self, $dbh) = @_; ########## -2- ########## local $dbh->{RaiseError}; print "localised \$dbh->{RaiseError}, became " . \$dbh->{'RaiseError'} . "\n"; print "\$dbh is $dbh\n"; ########## -3- ########## my @a = $dbh->selectrow_array("SELECT id FROM Tag WHERE id = 'ciao' +"); } ###################################################################### +## package main; my $dbh = DBI->connect("DBI:mysql:database=forecast_recurrent;host=localhost", "poletti", "", {'RaiseError' => 0, 'PrintError' => 0}); print "DB handler: $dbh\n"; my $c = new Category; $c->load_fromdb($dbh, 'HEAD'); print "\$c object holds " . scalar(keys %$c) . " elements\n"; $c->save_todb($dbh, 'TRY');
So, the offending SV actually is the localised hash element.DB handler: DBI::db=HASH(0x824be28) load_fromdb: got HASH(0x8231a10) $c object holds 0 elements localised $dbh->{RaiseError}, became SCALAR(0x81bf144) $dbh is DBI::db=HASH(0x824be28) Attempt to free unreferenced scalar: SV 0x81bf1f8.
Now, when I comment any line after a numbered comment, the error disappears. I may understand that commenting out the "offending" reference, i.e. line after comment #2, but I really cannot understand the other two!
Is it possible that's only a DBI bug, possibly resolved in latest versions? My "details":
TIA,poletti@flaviox ~> perl -v + This is perl, v5.8.6 built for i386-linux $DBI::VERSION = "1.40"; # From Slackware
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Yet Another DBI error
by RazorbladeBidet (Friar) on Apr 05, 2005 at 19:38 UTC | |
|
Re: Yet Another DBI error
by tlm (Prior) on Apr 05, 2005 at 19:26 UTC | |
|
Re: Yet Another DBI error
by NateTut (Deacon) on Apr 05, 2005 at 21:15 UTC | |
by Ven'Tatsu (Deacon) on Apr 05, 2005 at 21:43 UTC |