What I'm trying to do, is select column [ 13] with missing information and column [ 14] with no missing information
Unfortunately your line which does this is missing a digit. You have if ($column[13] eq "" && $column[4] ne "" ) which would do this if it said [14] instead of [4]. Is this your first problem?
#!/usr/bin/perl use warnings; use strict; my $filename = 'pedigree_proband_testfile.txt'; open (FILE, "<", $filename) or die "Cannot open file $!"; my @data = <FILE>; my @column; my $motherID; foreach my $line (@data) { @column = split ( /\t/, $line); if ($column[13] eq "" && $column[14] ne "" ) { print "DEBUG: $line"; # It isn't clear what you are trying to do below here $motherID = join($column[2],$column[4]); if ("$motherID" eq "$column[2]") { print "$line\t\n"; } } }
See item number 2 on the Basic debugging checklist for the use of debugging aids like this print statement.
In reply to Re: How to map data from one column based on another column in perl
by hippo
in thread How to map data from one column based on another column in perl
by waekit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |