package XML::PML;

use File::MMagic::XS;
use warnings;
use strict;
use 5.010;

=head1 NAME

XML::PML - Paragraph Markup Language tool

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';


=head1 SYNOPSIS

    use XML::PML;

    my $foo = XML::PML->new( filename = "FileName.ext");

=head1 METHODS

=head2 new

=cut

sub new {
    my ($self, %opts) = @_;
    return undef unless exists($opts{filename}) and -f $opts{filename};

    my $mm = File::MMagic::XS->new;
    $mm->add_file_ext('docx', 'application/stupidocx');
    $mm->add_file_ext('doc',  'application/msword');

    $opts{filetype} = $mm->get_mime($opts{filename});

    warn "Detected as $opts{filetype}...\n";
    my $type;
    given ($opts{filetype}) {
        $type = 'txt'  when /text.plain/;
        $type = 'docx' when /stupidocx/;
        $type = 'doc'  when /application\/msword/;
        default {
            warn "Filetype $opts{filetype} not yet handled on XML::PML\n";
            return undef;
        }
    }

    eval "use XML::PML::$type";
    return bless { %opts } => "XML::PML::$type" # amen
}

=head1 AUTHOR

Alberto Simoes, C<< <ambs at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-xml-pml at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-PML>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.




=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc XML::PML


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-PML>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/XML-PML>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/XML-PML>

=item * Search CPAN

L<http://search.cpan.org/dist/XML-PML/>

=back


=head1 ACKNOWLEDGEMENTS


=head1 LICENSE AND COPYRIGHT

Copyright 2010 Alberto Simoes.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut

1; # End of XML::PML
