[Clipart] Re: SVG support for getID3

Jonadab the Unsightly One jonadab at bright.net
Wed Mar 15 07:11:11 PST 2006


Bryce Harrington <bryce at bryceharrington.org> writes:

> > > Hmm, I also notice that mimetype is able to correctly determine the
> > > SVG-ness of the file:
> > > 
> > > $ mimetype daggers.svg
> > > daggers.svg: image/svg+xml
> 
> It's a perl script written by Japp G. Karssenberg in 2003.  Its manpage
> mentions the File::MimeInfo module.

Finally got around to looking at this.  It is matching the filename
against a list of patterns.  Here's the code that's doing it:

	if ($file =~ /\.(\w+(\.\w+)*)$/) {
		my @ext = split /\./, $1;
		while (@ext) {
			my $ext = join('.', @ext);
			print STDERR "> Checking for extension '.$ext'\n" if $DEBUG;
			warn "WARNING: wantarray behaviour of globs() will change in the future.\n" if wantarray;
			return wantarray
				? ($extension{$ext}, $ext)
				: $extension{$ext}
				if exists $extension{$ext};
			shift @ext;
		}
	}

Here is the result:

jonadab at vestibule$ rm test.svg
jonadab at vestibule$ touch test.svg
jonadab at vestibule$ mimetype test.svg
test.svg: image/svg+xml
jonadab at vestibule$

-- 
Open Clip Art Library:  Drawing Together
http://www.openclipart.org/




More information about the clipart mailing list