perlquestion
narashima
<p>
Revered monks,<br>
I am trying to compare 2 simple arrays <c>@file</c> and <c>@file2</c>.<br>
</p>
<p>
After the comparision I need:
<ol>
<li>matched elments</li>
<li>elements in <c>@file1</c> not in <c>@file2</c> and</li>
<li>elements in <c>@file2</c> not in <c>@file1</c></li>
</ol>
</p>
<p>I am using the following code... Is this the best way of doin it??? is there a optimization or even a direct function for this?</p>
<c>
%seen = ();
@seen{ @file1 } = ();
@infile1only = grep { ! exists $seen{$_} } @file2;
%seen =();
@seen{ @file2 } = ();
@infile2only = grep { ! exists $seen{$_} } @file1;
@matched = grep { exists $seen{$_} } @file1;
</c>
<p>
thanks,<br />
narashima
</p>