rkrish has asked for the wisdom of the Perl Monks concerning the following question:
Hi,I'm trying to return an array and a variable from a subroutine,but I'm unable to get the desired output,please help me in correcting the code below
The output I got is :my ( @subs, $SubId ) = getsubsFromAcct( $currAcct ); my $length = @subs; print ("No of subs : $length and subs are @subs"); sub getsubsFromAcct { my $acctNum = shift; my @subs = (); my ( $sbscrpId, $count ); my $getSbscrp_id = $lda->prepare("select sbscrp from sbscrp_cltn w +here acct_nbr = ? "); my $subsOfSbscrp = $lda->prepare("select distinct subs_time from s +bscrp_time where sbscrp = ? "); $getSbscrp_id->bind_param(1,$acctNum); $getSbscrp_id->execute(); $getSbscrp_id->bind_col(1,\$sbscrpId); if ( $getSbscrp_id->fetch) { $subsOfSbscrp->bind_param(1,$sbscrpId); $subsOfSbscrp->execute() while ( my @subRow = $subsOfSbscrp->fetchrow_array() ) { push(@subs,@subRow); } } return ( \@subs, \$sbscrpId ); }
No of subs : 2 and subs are ARRAY(0x2f8d10) SCALAR(0x2f8cf8)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Returning multiple values from a subroutine
by vinoth.ree (Monsignor) on Dec 28, 2012 at 11:49 UTC | |
by rkrish (Acolyte) on Dec 28, 2012 at 12:33 UTC | |
by muba (Priest) on Dec 29, 2012 at 02:19 UTC | |
|
Re: Returning multiple values from a subroutine
by McDarren (Abbot) on Dec 28, 2012 at 11:56 UTC |