Somewhat related: Take a look at
Data::Dumper. With it you can print out your data structures comfortably (great for debugging), and this is also the prefered method to tell others (for example perlmonks) what data structures you have or want to have.
Just try it out, it is already included in your perl:
use Data::Dumper;
print Dumper(\%matrix);