#/usr/bin/perl use strict; use warnings; $|=1; #turns stdio buffer off so that error line order is correct while (defined (my $line = )) { chomp $line; #removes end of line character(s) next unless $line =~ /\S/; # skip blank lines my ($motherId,$yearBirth,$individualId) = (split /\t/,$line)[4,13,2]; $yearBirth //= ""; # DATA line 6 is a bit weird # this defines $yearBirth as "" if undefined print "UniqId=$individualId Mother=$motherId BirthY=$yearBirth \n"; } =Prints UniqId=1 Mother=3 BirthY=51 UniqId=2 Mother= BirthY= UniqId=3 Mother=36 BirthY=65 UniqId=4 Mother=3 BirthY=50 UniqId=5 Mother=3 BirthY=47 UniqId=6 Mother=3 BirthY= UniqId=7 Mother=3 BirthY= UniqId=8 Mother=3 BirthY=42 UniqId=9 Mother=3 BirthY=39 UniqId=10 Mother=3 BirthY=35 UniqId=11 Mother=8 BirthY=11 UniqId=12 Mother=8 BirthY=9 =cut __DATA__ BC000 1 1 2 3 F 3 51 51 BC000 0 2 M 999 BC000 0 3 37 36 F 65 BC000 0 4 2 3 M 50 50 BC000 0 5 2 3 F 45 47 46 BC000 0 6 2 3 F 3 42 BC000 0 7 2 3 M 999 BC000 0 8 2 3 F 3 42 BC000 0 9 2 3 F 1 39 BC000 0 10 2 3 F 3 35 BC000 0 11 45 8 M 11 BC000 0 12 45 8 F 9