I think there are a couple of problems with your code:
- for my $item ( 0 .. @{$ref} ) is going to try to access an element beyond the end of the array. What you need here is $#{$ref}.
- $hash_ref = $ref->{$item}; should be $hash_ref = $ref->[$item]; as you are dereferencing an array, not a hash
Cheers,
JohnGG