Hi, well a clumsy way to do this would go something like this :
use Data::Dumper; %input=(r=>[1..10],s=>[1..10],t=>[5..10],u=>[11..20]); grep{$hash{"$input{$_}[0]_$input{$_}[-1]"}++;$tmp{$_}=$input{$_} if $h +ash{"$input{$_}[0]_$input{$_}[-1]"}==1}keys %input; print Dumper(\%tmp);
But if you play around with hashes you'll probably end up with some more clever solution :)

cheers

baxy

Update: Ups , I just sow some extra conditions Corion pointed out so i don't think this will work for you but this should :)

use Data::Dumper; %input=(r=>[1..10],s=>[1..10],t=>[5..10],u=>[11..20]); grep{$hash{$input{$_}[0]}->{$input{$_}[-1]}++;$hash_1{$input{$_}[0]}++ +;$hash_2{$input{$_}[-1]}++;$tmp{$_}=$input{$_} if ($hash{$input{$_}[0 +]}->{$input{$_}[-1]}==1 && $hash_1{$input{$_}[0]}==1 && $hash_2{$inpu +t{$_}[-1]}==1 )}keys %input; print Dumper(\%tmp); Output: $VAR1 = { 'u' => [ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], 'r' => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] };
(haven't tested it yet->possible bugs for you to remove:))

cheers


In reply to Re: Remove the duplication in Hash values by baxy77bax
in thread Remove the duplication in Hash values by Kandankarunai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.