http://www.perlmonks.org?node_id=905879


in reply to Remove the duplication in Hash values

If I understand correctly, you can't! Or at least, the array locations 0 and 0 thru 10 in the respective arrays in the output hash will have been autovivified giving existing addresses (test with exists()) populated however with undef(), although those above the upper limit you defined will not have come into existence.

Update: You probably want just arrays (ie reconsider the storage model) of [0..9] and to iterate them afresh for each key iteration of the containing hash when reading and writing to the hash.

Oops a cow flew by. Therefore a corrected response: There need to be clearer rules for the deletion - must the solution be contiguous? ie must it allow gaps if there is no other way to include a set that doesn't overlap another - what if two ranges overlap but are of the same size with one higher than the other - how is a winner selected between them?

One world, one people

Replies are listed 'Best First'.
Re^2: Remove the duplication in Hash values
by lidden (Curate) on May 20, 2011 at 10:54 UTC
    No, the [1..10] in %input=(r=>[1..10],s=>[1..10] is an array reference with values 1 to 10, which is possible. You cannot have an array without index zero, but nothing in the OP says he wants to do that.