in reply to Finding out whether a module contains a certain package
If you simply want to terminate with an exception, why not wrap the calls to Class::MixinFactory with an eval block. Maybe something like this (psuedocode)?
sub makeMixin { #input is an array of file names my @aImpliedPackageNames = map { ... } @_; my $class; eval { $class = MyClass->class(@aImpliedPackageNames); return 1; } or do { my $e=$@; # compute exception of your choosing, e.g. # a list of missing modules: my @aNotFound; foreach my $sPackage (@aImpliedPackageNames) { if (!eval("scalar keys %${sPackage}::")) { push @aNotFound, $sPackage; } } if (scalar(@aNotFound)) { die "Couldn't make mixin: the following packages " . "are undefined: @aNotFound"; } else { die $e; } } return $class; }
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding out whether a module contains a certain package
by rovf (Priest) on May 05, 2009 at 07:34 UTC | |
by ELISHEVA (Prior) on May 05, 2009 at 08:51 UTC | |
by rovf (Priest) on May 05, 2009 at 11:38 UTC |