sub matrixGet { my ($m, $x, $y, $z) = @_; return $m->[$x][$y][$z]; } ... matrixGet($o->{m},@{$h{$key}});