Couple of things:
An array reference starts at 0 and your reference object while, it is the third object in the list is going to be at location 2 not 3 in the array. Second you have a redundant check there and the "defined's" can be removed. The entire conditional statement can be simplified to this:
if ($elements[2]) {
print ("Parsing Error: Line $z\n");
if ($refList{$elements[2]}) {
print ("Already Present in file\n");
} else {
print "No match in reference file\n";
print (NEWALIGN $alignment->{$z}."\n");
print (NEWACC $elements[2]."\n");
}
}