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 ( #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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2023-02-07 08:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (38 votes). Check out past polls.

    Notices?