po4a-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Po4a-dev]Automatic loading of modules


From: Martin Quinson
Subject: [Po4a-dev]Automatic loading of modules
Date: Mon, 17 Feb 2003 15:00:56 +0100
User-agent: Mutt/1.5.3i

Hello,

For now, all the modules must be known to the special module Chooser.pm.
Here is its code:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
package Locale::Po4a::Chooser;

use 5.006;
use strict;
use warnings;

use Locale::Po4a::KernelHelp;
use Locale::Po4a::Html;
use Locale::Po4a::Man;
use Locale::Po4a::Pod;
use Locale::Po4a::Sgml;

require Exporter;

use vars qw($VERSION @ISA @EXPORT $AUTOLOAD);
$VERSION = $Locale::Po4a::TransTractor::VERSION;
@ISA = qw();
@EXPORT = qw(new list);

use Locale::gettext;

sub new {
    my ($module)=shift;
    my (%options)address@hidden;

    if (lc($module) eq 'kernelhelp') {
        return Locale::Po4a::KernelHelp->new(%options);
    } elsif (lc($module) eq 'man') {
        return Locale::Po4a::Man->new(%options);
    } elsif (lc($module) eq 'pod') {
        return Locale::Po4a::Pod->new(%options);
    } elsif (lc($module) eq 'sgml') {
        return Locale::Po4a::Sgml->new(%options);
    } elsif (lc($module) eq 'html') {
        return Locale::Po4a::Html->new(%options);
    } else {
        warn sprintf(gettext("Unknown format type: %s.\n"),$module);
        list(1);
    }
}

sub list {
    warn gettext("This version of po4a knows the following formats:\n".
                 "  - kernelhelp: The help messages associated with each kernel 
compilation option.\n".
                 "  - html: HTML documents (EXPERIMENTAL).\n".
                 "  - man: Good old manual page format.\n".
                 "  - pod: Perl documentation format.\n".
                 "  - sgml: either debiandoc or docbook DTD.\n");
    exit shift;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

As you can see, this code is pretty repetitive. I would like to find a way
to load all the modules present in Locale/Po4a/
This would allow us to make several packages, one for the main po4a modules
and binaries, and other ones for each module inducing special dependencies
(like Sgml.pm and Html.pm).


I think that it could be done with require instead of use, but I'm not sure
if it's the cleaner design, and wanted to have your advice before changing
anything.


Thanks, Mt.

-- 
If the facts don't fit the theory, change the facts.
          -- Albert Einstein




reply via email to

[Prev in Thread] Current Thread [Next in Thread]