Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007814]
help
Chatterbox?
[choroba]: Most coffees? Depends on the country :-)
[choroba]: oh, you mean a cup with no water.
[Discipulus]: you are rigth, gory details but i remember from dunnowhere that concetrate caffein is more effective than brown water almost coffe..
[LanX]: prepared both kinds a 100 times and thinks the amount of grind code is about the same
Discipulus less effective i mean
[LanX]: (french press vs espresso cooker )
[LanX]: s/code/coffee/
Discipulus progammer is an organism that transforms caffeine into software..

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2017-01-16 10:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (148 votes). Check out past polls.