Since you seem to be running Windows you might ask the system what is the content type according to it:

use Win32::Registry; use strict; { my %cache; sub GetContentType { my $ext = shift(); # well it's a filename at this point for ($ext) { s/^.*\.//; # now we extract the extension $_ = lc $_; } return $cache{$ext} if exists $cache{$ext}; my $key; $HKCR->Open('.'.$ext, $key) or return; my ($type, $value); $key->QueryValueEx('Content Type', $type, $value) or return; $cache{$ext} = $value; return $value; } } print "Foo.exe: " . GetContentType('Foo.exe') . "\n"; print "Foo.gif: " . GetContentType('Foo.gif') . "\n"; print "bar.exe: " . GetContentType('bar.exe') . "\n";
(If the code doesn't work for you it might be because I tested it with Win32::Registry2 installed.)

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Edit by castaway: Closed small tag in signature


In reply to Re: Finding out mime types... by Jenda
in thread Finding out mime types... by TwistedPear

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.