Hi Jordi, On Monday 20 September 2010 10:16:40 Jordi Durban wrote: > Hi all! > I have a file like this : >
> colum a colum b > uid = 1 uid = 4 > uid = 2 uid = 3 > uid = 3 uid = 2 > uid = 4 uid = 1 > > I'm trying to find those columns with the same numbers regardless the colum > they are. That's, in the example, the row 2 is identital to row 3. > So far, I have tried: > > my %seen_pair; > while (my $line = <IN> ){ > chomp $line; > my ($col_1, $col_2) = split (/\t/,$line); > if ($seen_pair{$col_1 }{$col_2} || $seen_pair{ $col_2 }{$col_1} > ){ Well, you don't appear to be adding the columns to %seen_pair. What I would do is this: 1. Extract the numbers as $n1 and $n2 (unless the rest of the strings in the columns are relevant. 2. Prepare a unique token out of them: {{{ my $token = join(",", sort { $a <=> $b } ($n1, $n2)); }}} Notice that I sort the numbers in order to get a unique set. Make sure the joined separator does not exist anywhere. 3. Store that in the hash, possibly with some data on the next column and compare against it. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ List of Portability Libraries - http://shlom.in/port-libs <rindolf> She's a hot chick. But she smokes. <go|dfish> She can smoke as long as she's smokin'. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/