in reply to Re^9: Class::DBI::AbstractSearch and SpeedyCGI
in thread Class::DBI::AbstractSearch and SpeedyCGI

Does the code where you call this do it exactly the same every time? There may be something subtle that changes it to list context on the third one. Can you show that part?
  • Comment on Re^10: Class::DBI::AbstractSearch and SpeedyCGI

Replies are listed 'Best First'.
Re^11: Class::DBI::AbstractSearch and SpeedyCGI
by zigdon (Deacon) on Oct 05, 2005 at 11:45 UTC
    The code is exactly the same, afaict. Here's the relevant code (note, it's ugly, most of it written before I know much perl).
    script.pl: opendir(DIR, $MyApp::Conf::SUBMITROOT) or die "Can't read dir: $!"; foreach (grep /^\d+(?:-\d+)?\.\d+$|^[\-\w]+\.\d+(?:\.jpg)?$|^set\.\d ++(?:-\d+)?\.\d+\.jpg$/, readdir DIR) { $h = {}; $h->{File} = $_; if (/^(\d+(?:-\d+)?)\.(\d+)$/) { ... } elsif (/^set\.(\d+(-\d+)?).(\d+)\.jpg$/) { # this is the case we +'re hitting $h->{Set} = $1; $h->{Set} .= "-1" unless $2; $h->{Timestamp} = $3; $h->{Pic} = 1; my $curpic = $db->GetSetPictures({SetID => $h->{Set}, PicID => 0 +}); $h->{New} = not keys %$curpic; } else { warn "Unknown file: $_"; next; } ---- in the $db object: sub GetSetPictures { my $self = shift; my ($param) = @_; croak "Bad params" unless exists $param->{SetID}; $param->{Self} = "/inv/sets/$param->{SetID}" unless exists $param->{ +Self}; my ($setinfo) = $self->GetSetInfo({Set => $param->{SetID}}); ... sub GetSetInfo { my $self = shift; my ($param) = @_; my %where; if (exists $param->{Set}) { if ($param->{Set} eq '*') { ... } else { if ($param->{Set} =~ /-\d/) { $where{ID} = $param->{Set}; # this is our case in all 3 itera +tions } else { ... } } } else { ... } my @res = MyApp::Sets->search_where(%where); # Class::DBI object wi +th the AbstractSearch plugin ...

    -- zigdon

      I don't see anything in this code that would explain it. I think you should try putting in some warn statements to show the value of wantarray() inside those subs, and then use the debugger to figure out exactly where that array ref changes.
        This is still driving me crazy. That one script stopped breaking (I couldn't tell you why), and another started. It (currently) breaks consistantly when I try to run it:
        $ perl ./hist2rss.pl hist2rss.pl: Attempt to free unreferenced scalar: SV 0x87edcb4 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x87e55bc at /hom +e/user/lib/modules/Class/DBI.pm line 1127. <h1>Software error:</h1> <pre>MyApp::Sets can't SELECT id, id, setnumber, setrev, name, theme, +year, pcs, figs, picture, msrp, instructions, inventory FROM SETS WHERE ( ID = ? ) : Not an ARRAY reference at /home/user/lib/modules/Class/DBI.pm line 1 +126. at /home/user/lib/modules/Class/DBI/AbstractSearch.pm line 32
        Ok, great, I say - I'll run it under the debugger, awesome. Well, not so much - I'm running it in the debugger, and just telling it to continue:
        $ perl -d ./hist2rss.pl Loading DB routines from perl5db.pl version 1.23 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(./hist2rss.pl:15): my $db = new MyApp::DB; DB<1> c hist2rss.pl: Attempt to free unreferenced scalar: SV 0x88044c0 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c47508 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c62818 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c62174 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c629f8 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c62b00 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c650d8 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c65294 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c65c6c at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c66c24 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. hist2rss.pl: Attempt to free unreferenced scalar: SV 0x8c65ec4 at /hom +e/user/lib/modules/Class/DBI.pm line 1127. Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB<1> exit
        And it just completes it's run without any error. What's the deal? Why would it NOT break under the debugger, without me doing anything?

        -- zigdon