<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div><br>#Hi Paola,<br>#this is the way I would do it, hope it can help.<br><br>use strict;<br><br># le due liste, che tu leggerai dai file, qua le ho valorizzate a caso per fare delle prove.<br>my @list1 = ( 1,2,3);<br>my @list2 = (2,3,4);<br><br># questo hash lo uso per contare quante volte mi si presenta un valore.<br>my %count;<br><br># lista che conterrà i numeri in comune.<br>my @common;<br><br># ciclo sulle due liste.<br>for my $num ( @list1 , @list2 )<br>{<br># ogni valore delle liste lo metto come chiave dell' hash e aggiungo 1, così conto quante volte ho trovato il numero.<br>$count{$num}++;<br>}<br><br>for my $num ( keys %count )<br>{<br># ciclo sulle chiavi dell' hash e metto i numeri che ho trovato più di una volta, nella lista @common.<br>push( @common , $num ) if $count{$num} &gt;
 1;<br>}<br><br># ti lascio la print, se vuoi stampare il risultato.<br>#print "$_\n" for @common;<br><br><br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">Da:</span></b> Paola Bisignano &lt;paola.bisignano@gmail.com&gt;<br><b><span style="font-weight: bold;">A:</span></b> milan-pm@pm.org<br><b><span style="font-weight: bold;">Inviato:</span></b> Martedì 6 ottobre 2009, 12:32:08<br><b><span style="font-weight: bold;">Oggetto:</span></b> [Milan-pm] comparing 2 lists<br></font><br>Hi,<br>I have two lists of numbers, saved in two files and I want to compare<br>them, in order to check which are the same elements in both lists. I<br>put them into array, so I want to compare array, but I only want to<br>check the value, and It doesn't matter for the position in the
 array,<br>I tried to use Array::Compare<br><br><br><br>open (OUT, "&gt; $file");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; my $comp = Array::Compare-&gt; new;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($comp-&gt;compare(\@array_num1, \@array_num2))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print "$comp\n";<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print OUT "$comp\n";<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; close OUT;<br><br>but it returns blank, I don't know why...<br>_______________________________________________<br>Milan-pm mailing list<br><a ymailto="mailto:Milan-pm@pm.org" href="mailto:Milan-pm@pm.org">Milan-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/milan-pm" target="_blank">http://mail.pm.org/mailman/listinfo/milan-pm</a><br></div></div></div><br>



      </body></html>