Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Passing a reference from a subroutine.

by Lotus1 (Curate)
on Dec 07, 2012 at 19:23 UTC ( #1007814=note: print w/replies, xml ) Need Help??

in reply to Passing a reference from a subroutine.

When you call the sub like this my $alldata= get_data(); you aren't passing anything to the subroutine. There is no data for it to get.

When you do this $one_num = $infs->{ $one_num }, where was the value for $one_num initialized? It doesn't look like it was initialized to anything so the value inside the brackets is going to be undef. Are you using warnings? Strict?

my $c = -1; ... foreach my $infs (@{ $data->{ info } }) { $c++; ... push @{ $AoA[$c] },

A more Perlish way to do this is to push each value into a temporary array inside the loop and then push that array into @AoA at the end of each itteration. This would drop out all the loop variables and simplify the notation.

Replies are listed 'Best First'.
Re^2: Passing a reference from a subroutine.
by Anonymous Monk on Dec 07, 2012 at 20:26 UTC
    Like this?
    ... my @temp_array; push @temp_array, $one_num, $$account_num, $name, $new_name, $plano, $ +passdate, $todays_date, $descont, $firm, $value, $thetotal, $commited +; push @{ $AoA[$c] }, @temp_array; } return @AoA; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007814]
Eily same

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2018-05-22 15:58 GMT
Find Nodes?
    Voting Booth?