title: Perl File Test for Text -T and PDFs
body: <p>I'm trying to limit my Perl-Tk code to only open text files to edit.  I'm testing to make sure the user selected a valid file (I'm using Tks <code>getOpenFile()</code> ):</p>
  
  <pre><code>if ( (defined $file) and (-f $file) and (-T $file) ) {
    #work with file
  }
  </code></pre>
  
  <p>The problem I've run into is that some PDF files pass the -T test and get opened (causing much chaos).  I tried this code in a directory full of PDFs:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  
  my @files = &lt;*&gt;;
  foreach (@files) {
    if (-T) { print "$_ is a text file\n"};
  }
  </code></pre>
  
  <p>About 1/2 the PDFs in the directory get printed.  </p>
  
  <p>Am I using -T wrong?  Will I have to add a regex to filter out PDFs?  And how come Perl thinks only some of the PDFs are text?</p>
  
  <p>EDIT: <code>-T</code> is a file test that should return true if the file is plain text.  I'm not trying to check for taint.</p>