in reply to file testing is hard

Well, with sysopen you can do that. Or with open. Check http://www.perldoc.com/perl5.8.0/pod/func/open.html to see how can you do it with open.