Perl

Moderators: Jonathan
Number of threads: 1236
Number of posts: 3605

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Getting two columns that begin with the same letter Posted by rbyn on 18 Dec 2012 at 9:03 AM
Hello all !

I have a file that has a list of plant genes and it looks like this:
01-0223: Os05g0168800 Sb09g005020 0.650 speciation
01-0224: Os01g0168200 Os05g0169000 1.083 WGD
01-0224: Os05g0169000 Sb09g005030 0.670 speciation
01-0225: Os01g0168300 Sb03g004660 0.522 speciation

I want to get the lines where column 2 and column 3 both begin with "O" and to ignore the lines where either column 1 or 2 begins with an "S"

I have tried this

use warnings;

open (FILE, "genes.txt");
while ( $line = <FILE>) {
chomp $line;
if ( [2,3] =~ "^O") {
print $line ;}
}
exit;

but it doesn't work.
Any ideas? Thanks !



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.