This code prints all the values just as it is split does not compare and print them as i want it.. The column1 data:#!/usr/bin/perl -w use strict; use warnings; use Getopt::Std; my $file = "lethal_results2.txt"; # input file containing nubiscan res +ults my $ge = "geneid.txt"; # file with TE name and length open(FILE,"<",$file) or die("Unable to open file $file: $!"); open(GE,"<",$ge) or die("Unable to open $ge: $!"); my @file_data = <FILE>; my @ge_data = <GE>; #input stored in an array close(FILE); close(GE); foreach my $line (@ge_data) { my @line = split(/\s+/,$line); my $start = $line[0]; #print"$line[0] \n"; foreach my $values(@file_data) { my @values = split(/\s+/, $values); my $id = $values[0]; #print"$values[0] \n"; my $width = 11; if ($values[0] eq $line[0]) { #print"the gene id \n"; print"$line[0] \n"; } } }
Column 2:ENSMUSG00000050310 ENSMUSG00000025583 ENSMUSG00000021198 ENSMUSG00000052595 ENSMUSG00000015243 ENSMUSG00000024130 ENSMUSG00000031333 ENSMUSG00000026842 ENSMUSG00000026596 ENSMUSG00000020532 ENSMUSG00000026003 ENSMUSG00000023328 ENSMUSG00000029580 ENSMUSG00000054808 ENSMUSG00000026836
In the second column the values are repeated so i want to compare the values in both columns and then print those present in both only once without repetition.ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000050310 ENSMUSG00000025583 ENSMUSG00000025583 ENSMUSG00000025583 ENSMUSG00000025583 ENSMUSG00000025583
In reply to Comparing two columns by Nalababu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |