In Perl there is a file test operator, -T, to see if a file is a text file. A text file in this context means a plain file where the first part of the file seems to contain text, rather than binary data.