Getting two columns that begin with the same letter - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Getting two columns that begin with the same letter

rbynrbyn Posts: 2Member
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 = ) {
chomp $line;
if ( [2,3] =~ "^O") {
print $line ;}

but it doesn't work.
Any ideas? Thanks !
Sign In or Register to comment.