Thank you so much guys for your kind help, I used the solution given by ikegami and it worked very well(and fast) for me. I found my answer and I am closing this thread. Thanks alot once again to all of you.

You can't (technically) "close" a thread. Indeed you solved your problem and that's fine. Now, one last remark is in order, in the hope that you will benefit from it: comparing your newly found solution

my @unique_pssns = grep { not exists $assns{$_} } @pssns;

with your initial attempt the lesson to be learned is that the choice of the data structure does matter in contrast with your assumption that "array or associative array doesn't matter". In particular you had homogeneous data "dispersed" across keys and values of given hashes with no sensible association between each key-value pair. Also, loading data from your flat files into hashes like that also will make you risk of losing some of it (specifically, different values associated to identical keys). For that naive two-loop approach an array would have been better. But when you have to check for existence, as a mnemonic remember of exists and think of a hash. This will get rid of one of the loops. Of course nobody prohibits you to have your main data stored into an array and to create a hash on the fly exactly for this purpose, as per ikegami's solution. As far as the other loop goes, it's still behind the curtain in grep but of course the latter as a higher level tool with a specific application highlights the logic and hides the details, not to mention the keystrokes it saves you.


In reply to Re^3: How to compare two associative arrays efficiently by blazar
in thread How to compare two associative arrays efficiently by viveks_19

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.