in reply to Re: multi-dimensional arrays, dereferencing
in thread multi-dimensional arrays, dereferencing

An "array of arrays" is in fact an array of references to arrays. So each element of your @M is an array reference leading us to:
foreach $aref (@M) {...
To get the actual array from an array reference, one usually writes @$aref leading us to
foreach $element (@$aref) {...
and that's all about it.