At 13:27 22/05/01 +0100, you wrote:

I don't know if you are parsing mail or something else, but in the past I've had luck 
with MIME::Parser using the effective_type() method to get the mime type out of emails.

If you are trying to figure it out magically based on just the file format or filename 
or something(e.g. just pointing it at a raw jpeg) I didn't think MIME:: would help. 
Could be wrong tho. Apache has some stuff that attempts to do this, but unless you 
fancy making your program a mod_perl handler that won't help you much.

use MIME::Parser;
my $parser = new MIME::Parser;
$parser->output_to_core(1);
$parser->decode_headers(1);

my $message;
my $errors;
### Parse input:
my $entity = $parser->parse(\*STDIN) or $errors .= "parse failed $!\n";

$message->{head} = $entity->head();
$message->{body}->{attachments} = []; #put attachments (if any) in here
if($message->{body}->{text} = $entity->bodyhandle()) # if it's single part 
{
        #if they've sent a message that _only_ contains non-text data as a 
         #single part
        if ($entity->effective_type !~ /text/)

...



-- 
Jonathan Peterson
Technical Manager, Unified Ltd, 020 7383 6092
[EMAIL PROTECTED]

Reply via email to