Hi all,
I have this piece of code:
my @modules = (
'Module1', 'Module2', 'Module3',
'ModuleX', 'ModuleY', 'Blah',
);
my $param1 = "whatever";
my $param2 = 0;
for my $module (@modules) {
$param2++;
eval("require $module");
if ($@) {
print "$module Not found\n";
} else {
eval("&${module}::process('$param1', '$param2')");
}
}
And it's working, but I wonder if there's any cleaner/better way to do this.
The main idea is to have a XML file like this:
<xml>
<file source="file1.txt" module="TextFile" parameters="1"/>
<file source="file2.csv" module="TextFile" parameters="2"/>
<file source="file3.xml" module="XMLFile" parameters="this and that"/>
</xml>
To tell me I have to do:
&TextFile::process('file1.txt', '1');
&TextFile::process('file2.csv', '2');
&XMLFile::process('file3.xml', 'this and that');
Got it? ;-)
Thanks!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>