MIME::Detect::Type - the type of a file
my $type = $mime->mime_type('/usr/bin/perl'); print $type->mime_type; print $type->comment;
$type->aliases
Reference to the aliases of this type
$type->comment
Array reference of the type description in various languages (currently unused)
$type->mime_type
print "Content-Type: " . $type->mime_type . "\r\n";
String of the content type
$type->globs
print $_ for @{ $type->globs };
Arrayref of the wildcard globs of this type
$type->extension
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.
$fn
globs
$type->priority
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.
$type->superclass
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 http://github.com/Corion/filter-signatures.
The public support forum of this module is https://perlmonks.org/.
Please report bugs in this module via the RT CPAN bug queue at https://rt.cpan.org/Public/Dist/Display.html?Name=Filter-signatures or via mail to filter-signatures-Bugs@rt.cpan.org.
Max Maischein corion@cpan.org
corion@cpan.org
Copyright 2015-2016 by Max Maischein corion@cpan.org.
This module is released under the same terms as Perl itself.
To install MIME::Detect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MIME::Detect
CPAN shell
perl -MCPAN -e shell install MIME::Detect
For more information on module installation, please visit the detailed CPAN module installation guide.