http://www.perlmonks.org?node_id=1084522


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,