in reply to Arrays/Lists of Hashes

I think your bug is here:

$inv->{ranges} = @ranges;

What you probably want is this:

$inv->{ranges} = \@ranges;

The backslash takes a reference to the array, @ranges. Without it, you're just putting that array in a scalar context, so $inv->{ranges} == 3 or whatever the number of elements in @ranges is.

You might be helped by looking at How can I visualize my complex data structure? as well as perlreftut, and perlref.