I'd like to use MIME::Lite to take arbitrary data as input and send an email with that data as an attachment. I presume that to do this I need to get the MIME type correctly set. So I'm looking for something that can examine that stream of arbitrary, presumably binary, data, and then spit out the MIME type, or else something that I can use to derive the MIME type.
Basically, I'm looking for the "file" command in Perl. I was just remarking with a co-worker the other day how "file"'s database is an incredible resource and how that utility really does an amazing job figuring out what formats things are. It takes a hard job that can never been done perfectly, and does it intelligently. (Actually, that's my definition of artificial intelligence. Maybe "file" is sentient.)
I thought of looking to see if Perl Power Tools has a file command, but ppt.perl.org seems to be unreachable from my position in time and space, and I'm not really sure I want to download the entire distribution and pore through it, especially since whatever I find probably won't be a library, anyway. I did find a module called MIME::Types, updated as recently as May of this year, but it doesn't really do this job; it will give me a MIME type based on a file extension or based on a filename, which does me no good since STDIN doesn't come with a filename.
Even if I need to do this some other way, or don't need to do this at all to achieve my goal, I'm still curious if anything like this exists.