the code is currently working and i've used data::dumper to confirm my data structure. $array is used later in code not shown as it is not relevant to the question.
it sounds like you don't have an alternative to hardcoding the dimensions, either! that's good to know, maybe my solution is the only way....