Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Passing a reference from a subroutine.

by Lotus1 (Chaplain)
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.


Comment on Re: Passing a reference from a subroutine.
Select or Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-07-11 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (222 votes), past polls