Hi, I have asked this question before , but as Admin said If i want to change my question , I have to ask new question instead of asking by answering the previous one, Anyhow, my question is :
I want to read through 2 different tab-delimited files of sequence coordinates and find the same columns entries in both files and print it out , one file is ref and the other one contains the the columns that I want to find in the ref file : I want to keep col1 - col2 and col3 of file one (ref file) and col1 - col2 - col 3 of file2
file one (ref file) :
Col1 Col2 Col3 Col4 Col5 ColX
chr start end (rest columns)
file2 :
Col1 Col2 Col3 Col4 Col5 ColX
chr start end (rest columns)
I have written script but I got error when i print it out :
Use of uninitialized value $line2 in split at ./match3.pl line 19, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in string eq at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value $values2[0] in concatenation (.) or string at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in concatenation (.) or string at ./match3.pl line 22, <$fh2> line 2458.
Use of uninitialized value in concatenation (.) or string at ./match3.pl line 22, <$fh2> line 2458.
my script is :
#!/usr/bin/perl
use strict;
use warnings;
open my $fh1, '<', 'file1';
open my $fh2, '<', 'file2';
my$line1 ;
my$line2 ;
while (<$fh1>) {
chomp;
my @values1 = split( "\t", $line1 );
close $fh1;
while (<$fh2>) {
chomp;
my @values2 = split( "\t", $line2 );
close $fh2;
if ( $values1[0] eq $values2[0] and $values1[1] eq $values2[1] and $values1[2] eq $values2[2])
{
print "$values2[0] \t $values2[1] \t $values2[2] \t \n" ;}}}
Thanks In Advance,