perlkhan77 has asked for the wisdom of the Perl Monks concerning the following question:
Say I have a table which has values in two columns :- Column1 = $var1 and Column2 = $var2 (note they are both chromosome coordinates so they are bound to be repeated in different columns sometimes).Now I want to store them in a hash such that there is only one instance of $val1 and $val2 in both the keys and values of that hash. How can I achieve it. This is what I have tried so far but it does not works :- Any help would be appreciated
use strict; use warnings; while(<>){ my @val = split/\t/; if (exists $hash_chr{$val[$#val]}){ next; } else{ $hash_chr{$val[0]}=$value[$#val]; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash with both values and keys unique to each other
by toolic (Bishop) on Jul 12, 2012 at 17:07 UTC | |
| |
|
Re: hash with both values and keys unique to each other
by locked_user sundialsvc4 (Abbot) on Jul 12, 2012 at 20:47 UTC | |
|
Re: hash with both values and keys unique to each other
by Anonymous Monk on Jul 12, 2012 at 17:57 UTC | |
by perlkhan77 (Acolyte) on Jul 12, 2012 at 19:19 UTC | |
by Anonymous Monk on Jul 12, 2012 at 22:14 UTC | |
|
Re: hash with both values and keys unique to each other
by Anonymous Monk on Jul 12, 2012 at 17:03 UTC | |
by cheekuperl (Monk) on Jul 12, 2012 at 17:16 UTC |