Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
go ahead... be a heretic
 
PerlMonks  

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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2014-04-20 14:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (485 votes), past polls