in reply to defined of a matrix

Your 2nd test would be better as
if (ref $test[1] and exists $test[1][1]) {}
It occurs to me that a sub that returns the passed value iff it is a ref might provide some shorthand for this idiom:
sub iff_ref { return ref $_[0] ? $_[0] : undef; } # Then your test becomes (if exists doesn't mind the notation) if (exists iff_ref($test[1])->[1]) {} # or it might have to be if (exists ${iff_ref($test[1])}[1]) {}
I don't have perl5 where I am today, so this is absolutely untested.

We're not really tightening our belts, it just feels that way because we're getting fatter.