snowy has asked for the wisdom of the Perl Monks concerning the following question:
Hi there
I have two files "signal" which contain a list of all possible molecules. For example
and another file "orderednames" which is tab delimited containing some of the molecules and their other names5-HT 5-HT1BR serotonin MAP-kinase MAPK MAP-kinase-kinase
5-HTt serotonin MAP-kinase MAPK ERK
I would like to print all the molecules in "signal" which are not in the tab delimited file "orderednames"
At the moment my code prints out if the tokens from the tab file match from the signal molecules file which is sort of the oppisite of what I want.
use strict; use warnings; my $tok; my @tokens; my %hash; open INFILE, "<signal.txt" or die "can't open file"; while (<INFILE>) { chomp; $hash{$_} = undef; } close INFILE; open DATA, "<orderednames.txt" or die "can't open sentences"; while (<DATA>) { @tokens = split(/\t+/, $_); foreach $tok (@tokens) { if (exists($hash{$tok})) { print " match $tok \n" ; last; } else { print "$tok not match \n"; } } } close DATA; exit;
Thanks for your help in advance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: searching and printing what is wanted
by DamnDirtyApe (Curate) on Jul 04, 2002 at 22:41 UTC | |
|
Re: searching and printing what is wanted
by ehdonhon (Curate) on Jul 04, 2002 at 22:23 UTC | |
|
Re: searching and printing what is wanted
by DamnDirtyApe (Curate) on Jul 05, 2002 at 06:52 UTC | |
by theorbtwo (Prior) on Jul 05, 2002 at 07:19 UTC | |
|
Re: searching and printing what is wanted
by Abigail-II (Bishop) on Jul 05, 2002 at 09:53 UTC |