http://qs321.pair.com?node_id=151941

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

@retval is not returning $itm, it returns nothing at all... I wonder why??
#==================================================================== sub build_tree_for_cid($) { my ($cid) = @_; print "The cid we are seeking:"; print "$cid\n"; my $item = new Item; $item->id($cid); $item->type(-1); find_subs(\$item); return $item; } #==================================================================== sub find_subs(\$) { my ($item) = @_; print Dumper $$item; my $SQL; if ($$item->type == -1) { my $id = $$item->id; print "printing the item id\n"; print "$id\n"; $SQL = qq[SELECT uc.puid, up.prod_id FROM users_customers uc, user_products up WHERE ((uc.puid = up.puid) AND (uc.cid = $id) AND (up.from_date < SYSDATE) AND (up.to_date IS NULL OR up.to_date > SYSDATE))]; } else { my $id = $$item->id; print "printing the item id\n"; print "$id\n"; $SQL = qq[SELECT u.puid, up.prod_id FROM users u, user_products u +p WHERE ((u.puid = up.puid) AND (u.parent_puid = $id) AND (up.from_date < SYSDATE) AND (up.to_date IS NULL OR up.to_date > SYSDATE))]; } ${$item}->subs(my_execer($SQL)); print Dumper $$item; foreach my $subitem ($$item->subs) { find_subs(\$subitem); } return $item; } #==================================================================== sub my_execer($) { my ($sql) = @_; print "$sql\n"; my $sth = $dbh->prepare($sql) || undef; $sth->execute() || die "sth->execute: $DBI::errstr"; my @row; my @retval; if (@row = $sth->fetchrow_array) { my ($puid, $prod_id) = @row; print "printing weird stuff\n"; print "$puid\n"; print "$prod_id\n"; my $itm = new Item; $itm->id($puid); $itm->type($prod_id); print Dumper $itm; push (@retval,$itm); } $sth->finish; print "\@retval contains $#retval \n"; return (@retval); } #====================================================================