It is funny, out of that entire post I did not see a valid recommendation at all. All I saw was bashing of others recomendations.
An easy (but not fool proof) way of distinguishing between a text file or a binary file is use the ready-made -B file check operator. Or the -T (depending on which way your flag flies).
print "File is binary\n" if (-B);
print "File is a text file\n" if (-T);
or if you are a "NOT" guy/girl the following might suit your fancy.
print "File is binary\n" if (!-T);
print "File is a text file\n" if (!-B);
Hope that helps some.