My initial thoughts are that "program A" might be the best place to be adding this error checking and logging. Not sure if modifying "program A" is an option.
Another route would be to have the Perl script check periodically to see if "program B" is still running. Of course, this method might not be able to distinguish between a) up and running properly and b) running but not responding.
The only other way that I can think of is to have the Perl script periodically check on the file that "program A" is writing to. You could use something like stat to check for the last modified time stamp. I haven't use this module, but it looks File::Monitor might be another method for checking to see if the file has changed.
Perhaps more knowledgable and experienced monks can come up with better solutions/ideas. Thought I'd toss out these ideas in case one of them might help you out.