my @result = # note @ variable not $variable !! (($beginning, $agency, $district, $ssn, $serv_per_m, $serv_per_y, $serv_per_t,.............); while () { print; my @result = (.....blah) #see previous posters code my $token_nr=0; foreach my $token (@result) { $token_nr++; if (defined ($token) ) #if you try to print an undef { #program will bomb print "$token_nr++\t$token\n"; #this allows you to see exactly } #what is undef without program else #bombing { print "$token_nr++\tUNDEFINED\n"; } } }