I've finally uploaded a module to CPAN.
File::Type uses magic to find out the type of a file, like file(1). Of course, the observant will point out that this merely duplicates the functionality of File::MMagic (and, the eager CPAN watcher will note, File::MimeInfo).
However, there are a couple of problems with both of those modules. File::MimeInfo doesn't use magic at all yet, but merely glob patterns. It also doesn't ship with the magic file it references.
File::MMagic is the canonical solution to the problem, and it does include a magic file (inlined into MMagic.pm itself). Each time File::MMagic is run, it recreates the rules it needs to match by parsing that inlined magic. This means it uses seeks within a __DATA__ block, which causes problems within mod_perl. File::Type, by contrast, uses a seperate module (File::Type::Builder, which is included in the distribution, as is a magic file) to generate Perl code which is then included in File::Type itself. This means that the module can be very simple indeed, and it's safe to use under mod_perl.
However, as the version number should warn you, File::Type is still quite young. While it creates a few hundred rules from the magic file, there are still a hundred or so that it ignores because I haven't written the code generators for their pattern types. It's fine for many types of file (as the included tests show), though.
After releasing the main module (and the obligatory 'doh, need to bugfix' release), I thought it'd be fun to see if I could make an equivalent to File::Find::Rule::MMagic, which adds the ability to filter File::Find::Rule searches by mime type. It appeared on CPAN as File::Find::Rule::Type yesterday evening.