The problem is that for @{$cacheHOA{$sum}}
to be an array, then $cacheHOA{$sum}
must be an arrayref. You are trying to use $cacheHOA{$sum} as a string and an arrayref,
but perl only has it as the last thing it was set has,
which appears to be string (the file name) in this case.