That highly depends on what you mean by "a package with the name $name". Although Perl has the keyword package, it doesn't have a first or even second class object which is a "package".
I see. This makes it more tricky.
Right now, Class::MixinFactory works as follows: The creation function gets an array of names, say qw(Abc Xyz), and assumes that files Abc.pm Xyz.pm. Conceptionally, each of these modules is supposed to define a so-called mixin (which is done by defining the functions in those modules within packages Abc and Xyz, respectively). These "mixins" are not real classes (they don't have any constructor are nevere "blessed"); MixinFactory now makes out of these mixin-classes a new class (with a class/package name created at runtime), and this new class combines all the functions of the individual classes (plus a few more added by MixinFactory).
Everything works fine if it is really setup that way, but consider the case if, due to an error, MixinFactory gets the list qw(Abc Uvw) or qw(Abc xYz) instead of qw(Abc Xyz) This can happen, because the names inside the qw() list actually come from an outside source (I know that this is a security hole, but let's aside this issue for the moment). The first case would still be harmless: MixinFactory would find that a file with the name Uvw.pm does not exist, and throw an exception, which we catch.The second case would be harmless on Unix, for the same reason: MixinFactory would find that a file with the name xYz.pm does not exist, and again throw an exception.
The second case causes trouble, however, when you are on Windows. In Windows you can open successfully the file "xYz.pm", despite the "real" name of the file is "Xyz.pm", because Windows is not case sensitive. However, when MixinFactory tries to create the mixin class, it wants to make a mixin out of Abc and xYz, but the functions are defined in package Xyz, and it terminates the program.
Since we have control over the mixin modules, we can ensure that a module Xyz.pm indeed contains a package of the right spelling, Xyz, so it would be sufficient to protect agains a missspelling in upper/lower case on Windows. But I think this is not easy either, isn't it? RonaldIn reply to Re^2: Finding out whether a module contains a certain package
by rovf
in thread Finding out whether a module contains a certain package
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |