http://www.perlmonks.org?node_id=11135332


in reply to Question regarding a regex

Depending on your definition of 'text file', this test could give a false negative if the file contained any non-ASCII 'text'. It could give a false positive if every byte of a 'binary' file happened to contain the code of an ASCII character. (Can you tolerate an extremely rare error?)
Bill