Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: NON Common Elements between two columns

by Cristoforo (Deacon)
on Jul 17, 2012 at 22:59 UTC ( #982347=note: print w/replies, xml ) Need Help??

in reply to NON Common Elements between two columns

aitap's solution works fine, but I did a version using only 1 hash (and 1 array).
#!/usr/bin/perl use strict; use warnings; my (@genes, %tested); while (<>) { s/^>//; my ($col1, $col2) = split; push @genes, $col1; $tested{$col2}++; } { local $\ = "\n"; for (@genes) { print if not $tested{$_}; } }
When reading from the empty, <>, brackets, a file to read from has to be typed at the command line. For this program, I had the contents in file o33.txt.
C:\Old_Data\perlp>type o33.txt >chr9:133738100-133738472_0 chr20:62159728-62161126_840 >chr9:133738100-133738472_60 chr2:215589720-215676478_59220 >chr9:133738100-133738472_120 chr2:215589720-215676478_59160 >chr9:133738100-133738472_180 chr15:99500240-99507809_0 >chr9:133738100-133738472_240 chr2:215589720-215676478_59100 >chr9:133738100-133738472_253 chr1:162745876-162746210_215 >chr9:133747466-133747650_0 chr5:108523084-108532592_960 >chr9:133747466-133747650_60 chr20:62159728-62161126_900 >chr9:133747466-133747650_65
Then, my command line was the name of the program, followed by the name of the file to read from, o33.txt.
perl o33.txt

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982347]
[choroba]: Tire chains are mandatory here in mountains, and the only unprepared each year are gritters
[stevieb]: I have a 3 day winter survival kit in my vehicle in the event I get snowed in in the mountains (which has happened before due to avalanches closing the roads (and once in the summer due to a massive forest fire that trapped us
[perldigious]: a handful of people in my work area did not make it, but I live pretty close and it's flat the whole way, so I didn't have any trouble. The roundabout is the worst thing I have to negotiate.
[thezip]: G'day all!
[perldigious]: Well, that and dodging the people who forget how ice works right away. :-)
[stevieb]: hey, thezip
[perldigious]: I don't miss having to drive up and down in elevation on roads that are iced over, I white knuckled gripping the steering wheel every time I had to where I used to live.
[perldigious]: So I don't envy you mountain guys if you have to drive in the winter, even with tire chains.
MidLifeXis waves.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2016-12-06 16:40 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.