the File::Type module, although not bad, is clearly less accurate that file.

You've misunderstood something. The explicit purpose of File::Type is "to determine the MIME type of that file".

'image/jpeg' is a valid MIME type. 'JPEG image data, JFIF standard 1.01' is not. MIME types are important, eg, in internet transfers -- your browser decides how to treat something based on the MIME type in the http header.

The file command (which will give you a mime type too, if you use the --mime switch) can provide more detailed information in a "human readable" form but there is no protocol for this. It looks to me like someone has written a module porting "file" into perl tho: file.

However, since the author admits "this implementation is significantly slower than the C version" you might be better off just using backticks ;).


In reply to Re: file command replacement (showing the type of a file with perl) by halfcountplus
in thread file command replacement (showing the type of a file with perl) by pvaldes

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.