in reply to Why are this pattern match failing ?

Did you mean...?

if ($d[0] =~ /NA/){

or

if ($d[0] eq "NA"){

Since pattern matching defaults to the $_ variable, what you wrote is interpreted as if($d[0] eq ($_=~/NA/). Probably $_ is undefined, and that is causing the Use of uninitialized value message.

citromatik