Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
@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); } #====================================================================

In reply to subroutine not returning expected value by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-10-21 17:56 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (83 votes). Check out past polls.