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.

Here's the code:
#!/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');
which yields:
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.
So, the offending SV actually is the localised hash element.

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":

poletti@flaviox ~> perl -v + This is perl, v5.8.6 built for i386-linux $DBI::VERSION = "1.40"; # From Slackware
TIA,

Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

Don't fool yourself.

In reply to Yet Another DBI error by polettix

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.