MIME::Detect::Type - the type of a file


    my $type = $mime->mime_type('/usr/bin/perl');
    print $type->mime_type;
    print $type->comment;



Reference to the aliases of this type


Array reference of the type description in various languages (currently unused)


    print "Content-Type: " . $type->mime_type . "\r\n";

String of the content type


    print $_ for @{ $type->globs };

Arrayref of the wildcard globs of this type


    print $type->extension; # pl

Returns the default extension for this mime type, without a separating dot or the glob.

$type->valid_extension( $fn )

    print "$fn has the wrong extension"
        unless $type->valid_extension( $fn );

Returns whether $fn matches one of the extensions as specified in globs. If there is a match, the extension is returned without dot.


    print $type->priority;

Priority of this type. Types with higher priority get tried first when trying to recognize a file type.

The default priority is 50.


    my $sc = $type->superclass;
    print $sc->mime_type;

The notional superclass of this file type. Note that superclasses don't necessarily match the same magic numbers.

$type->matches $buffer

    my $buf = "PK\003\004"; # first four bytes of file
    if( $type->matches( $buf ) {
        print "Looks like a " . $type->mime_type . " file";


The public repository of this module is


The public support forum of this module is


Please report bugs in this module via the RT CPAN bug queue at or via mail to


Max Maischein


Copyright 2015-2018 by Max Maischein


This module is released under the same terms as Perl itself.