How people usually do that? Would extracting the subtype from the path (the file name) be a good idea? I would assume that whatever after the last period (.) would be its subtype; e.g.
if the file path is c:\my_music\file.mpeg
I could just split that and extract the last element??
Thank you for any suggestions,
Mariusz
From: Bob Showalter <[EMAIL PROTECTED]>
To: 'mario kulka' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: extracting
Date: Tue, 4 Feb 2003 12:34:22 -0500
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
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]