in reply to Multidimensional array

Maybe Mdevices only has one record in it? You only show a single push of an array reference into it. You can use Data::Dumper to help visualize your data structures.
use Data::Dumper; print Dumper(\@Cdevices); print Dumper(\@Mdevices);

This may also be of use: References quick reference