Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^9: Class::DBI::AbstractSearch and SpeedyCGI

by zigdon (Deacon)
on Oct 05, 2005 at 04:38 UTC ( #497486=note: print w/replies, xml ) Need Help??

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

Very interesting (and I'll try to see how this applies here) - but why would it only hit on the 3rd iteration, but not the first two? In all cases it was an arrayref with a single element?

-- zigdon

  • Comment on Re^9: Class::DBI::AbstractSearch and SpeedyCGI

Replies are listed 'Best First'.
Re^10: Class::DBI::AbstractSearch and SpeedyCGI
by perrin (Chancellor) on Oct 05, 2005 at 04:43 UTC
    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?
      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). 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://497486]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2019-05-27 11:32 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (156 votes). Check out past polls.