#/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,$what) = (split /\|/,$line)[4,13,2,14]; $yearBirth //= ""; # DATA line 6 is a bit weird # this defines $yearBirth as "" if undefined $what //= ""; # I don't know what this is? print "UniqId=$individualId Mother=$motherId BirthY=$yearBirth What=$what\n"; } =Prints UniqId=1 Mother=3 BirthY=51 What= UniqId=2 Mother= BirthY= What=999 UniqId=3 Mother=36 BirthY=65 What= UniqId=4 Mother=3 BirthY=50 What=50 UniqId=5 Mother=3 BirthY=47 What=46 UniqId=6 Mother=3 BirthY= What= UniqId=7 Mother=3 BirthY= What=999 UniqId=8 Mother=3 BirthY=42 What= UniqId=9 Mother=3 BirthY=39 What= UniqId=10 Mother=3 BirthY=35 What= UniqId=11 Mother=8 BirthY=11 What= UniqId=12 Mother=8 BirthY=9 What= =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|