Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: local and global variable problem

by Athanasius (Archbishop)
on Apr 30, 2014 at 15:59 UTC ( [id://1084522]=note: print w/replies, xml ) Need Help??


in reply to local and global variable problem

Hello madM,

I’m assuming that each call to $matrix->{$key}->{$key2} returns a single scalar value? In any case, each time the assignment:

@matrix_numbers = $matrix->{$key}->{$key2};

is executed, it overwrites the array @matrix_numbers with a new value. What you need is:

push @matrix_numbers, $matrix->{$key}->{$key2};

See push.

(I don’t understand why the array is empty — it should contain some value after the two foreach loops end.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: local and global variable problem
by madM (Beadle) on Apr 30, 2014 at 16:04 UTC
    thank you! i forgot it ;=)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1084522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-24 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found