Generally I can find and fix a problem like this. But this time it seems like something else is involved. The message, in the title of this post, appears from only line 123, and not on the previous lines. I do this same type of 'if' in other places with no messages. When I copy the code to a small test case, it works fine. I have verified with the debugger and print statements that the variables involved are defined. for ($sdd=0; $sdd <= $#gSDDdata; $sdd++) { # foreach SDD for ($srs=0; $srs <= $#gSRSData; $srs++) { # foreach SRS if (not defined $gSDDdata[$sdd]{source}) { print "m \n"; } elsif (not defined ($gSRSData[$srs]{sect})) { print "n \n"; } if ($gSDDdata[$sdd]{source} =~ /$gSRSData[$srs]{sect}/) { # <- 123 $gSRSData[$srs]{found} = $gSDDdata[$sdd]{found} = 1; } } }