in reply to How not to check if a module is installed
The way it's done now allows for the mutual inclusion of two modules. The way you suggest would cause an infinite loop.
The way it's done now takes into consideration that the re-running a module that failed in an uncontrolled fashion is a bad idea.
If the module dies in a controled fashion (by returning a specific value or by throwing a specific exception indicating it's safe to reload the module), you can circumvent the %INC check by using do or by clearing the appropriate entry in %INC.
(my $module = "$class.pm") =~ s{::}{/}g; if (!eval { require $module }) { die $@ if ((my $e = $@) !~ /.../); # Fix something ... # Try again delete $INC{$module}; require $module; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How not to check if a module is installed
by xdg (Monsignor) on Oct 24, 2007 at 16:42 UTC |