If that's all you need it for, I'd probably use the shorter, and more informative, file command (available on every Unix and Unix-like system that I've used in the last 40 years) rather than a Perl one-liner.

$ file /usr/bin/perl /usr/bin/perl: PE32+ executable (console) x86-64 (stripped to external + PDB), for MS Windows, 11 sections $ file /usr/bin/perl > file_perl $ file file_perl file_perl: ASCII text $ perle 'say -T "/usr/bin/perl" ? "text" : "binary"' binary $ perle 'say -T "file_perl" ? "text" : "binary"' text

In case you haven't yet picked up on ++eyepopslikeamosquito's reference:

$ alias perle alias perle='perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::Always -E +'

— Ken


In reply to Re^2: How to use the -T file op as a one-liner by kcott
in thread How to use the -T file op as a one-liner by kwolcott

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.