$SWMetal::Buffs::wsc_list_images = \&WSC::Image::list_images; *WSC::Image::list_images = sub { my($self,$msg) = @_; my $dbh = $self->{dbh}; my $itemID = $self->{apr}->param('itemID'); my $query = "SELECT size,cloth,ply,stitch FROM buffs WHERE itemID=?"; my $sth = $dbh->prepare($query); $sth->execute($itemID) or $self->error($sth->errstr()); my @qparams = $sth->fetchrow(); $sth->finish(); if(@qparams) { my $query = "SELECT itemID FROM buffs WHERE size=? AND cloth=? AND ply=? AND stitch=?"; $sth = $dbh->prepare($query); $sth->execute(@qparams) or $self->error($sth->errstr()); my @IDs = (); while (my $itemID = $sth->fetchrow()) { push(@IDs,$itemID); } $sth->finish(); # commenting out this line stops the infinate call $self->{apr}->param(itemID=>\@IDs); } $wsc_list_images->(@_); };