mario kulka wrote:
> Hi,
> While uploading a file my $type outputs as "audio/mpeg"
> What's the simplest way to extract just the extension (in this case
> mpeg)? 

Properly speaking, that's not an extension, but rather a "subtype". RFC 2045
gives you all the gory details on extactly how Content-type is formatted:

http://www.isi.edu/in-notes/rfc2045.txt

> 
> I thought to do this:
> ($not_needed,$extension) = split;

But that will split on whitespace, when you need to split on a slash. That
would be:

   (undef, $subtype) = split '/';

> 
> But can
> $type = $info->{'Content-Type'}
> output something in other formats with more elements? (e.g.
> audio/something/mpeg) Or is it always in the format
> type/file_extansion? (e.g. audio/type)

You don't have multiple slashes, but you can have additional info after the
subtype. For example:

   text/plain; charset=us-ascii

You should check out the MIME::Types module on CPAN, which can give you the
extension associated with a MIME type (by looking in your Win32 registry, I
guess?), if that's what you're after


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to