VALUE:while($file[$j][$n] =~ /\b\.+\b/gi) # while there is still a digit there (i.e. not a name #### my @file; push @{$file[0]}, qw (YAL038W 1.1 2.4 4.1 YCL040W 99.2 1.1 1.6 1.8 9.11 0.040212811); push @{$file[1]}, qw(YDR223W 99 4.7 0.0085523710); push @{$file[2]}, qw(YDL188C 1.5.4 10.3.1 13.32 YGL134W 01.05.04 02.19 0.083130297); $rows = 3; my %seen; @pathway_name = (1, 2, 4, 99); #### VALUE:while($file[$j][$n] =~ /^[\.\d ]+$/) #### Pathway is 1 Gene: YAL038W, Value: 1.1 printed to output file Gene: YDL188C, Value: 1.5.4 printed to output file Pathway is 2 Gene: YAL038W, Value: 2.4 printed to output file Pathway is 4 Gene: YAL038W, Value: 4.1 printed to output file Gene: YDR223W, Value: 4.7 printed to output file Pathway is 99