http://qs1969.pair.com?node_id=1176963


in reply to how to get average of matrices' elements?

The first time through your nested for loops, @m_avrg is uninitialized. You can uninitialized with:
my @m_avrg; for my $i ( 0 .. 2 ) { $m_avrg[$i] = [ map { $_ = 0 } 1 .. 3 ]; # $m_avrg[$i] = [ map { $_ => 0 } 1 .. 3 ]; # WRONG! }

UPDATE: I copy'n'pasted the wrong code originally. Yes, Anon's x operator is better.

See also: Basic debugging checklist

Use 4 single spaces for each level of indentation.