The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Alvis::Document::Type - Perl extension for guessing and checking the type of a document (an extension of MIME types).

SYNOPSIS

 use Alvis::Document::Type;

 # Create a new instance
 my $t=Alvis::Document::Type->new(defaultType=>'text',
                                  defaultSubType=>'html');
 if (!defined($t))
 {
    die('Ugh!');
 }

 my ($doc_type,$doc_sub_type)=$t->guess($doc_text);
 if (!(defined($doc_type) && defined($doc_sub_type)))
 {
    die("Guess what? " . $t->errmsg()); 
 }

DESCRIPTION

Tries to guess the type of a document similarly to MIME types (type and a subtype).

Adds subtypes 'rss' and 'html' to MIME type 'text'.

METHODS

new()

Options:

    defaultType       The default type (text).
    defaultSubType    The default subtype (plain).

guess($text)

Tries to guess the type of $text.

errmsg()

Returns a stack of error messages, if any. Empty string otherwise.

SEE ALSO

AUTHOR

Kimmo Valtonen, <kimmo.valtonen@hiit.fi>

COPYRIGHT AND LICENSE

Copyright (C) 2006 by Kimmo Valtonen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.