You should be aware that if your
input file has anything in front of the tag set you specified, your program will break. For instance, if the test file's last line contains "Some stuff</ab><cd>3410</cd>" then running the commands you show will set $chk = "Some stuf" and you won't ever know whether the file contained your markers or not!
You could use
tail -n 1' to just pick off the final line. Then use
regexp to pull out and test the tag of interest from the final line, i.e.:
my $final_line = `tail -n 1 $test_file`;
if ($final_line =~ m#</ab><cd>#) {
print "\n Needs to be processed \n";
}
else {
print "\n No need to process\n"
}