[svn:p5ee] r6341 - p5ee/trunk/App-Context/lib

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Thu May 25 10:48:26 2006
New Revision: 6341

Modified:
   p5ee/trunk/App-Context/lib/App.pm

Log:
App->use() now detects entries in the symbol table to inhibit an attempt to load the module

Modified: p5ee/trunk/App-Context/lib/App.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App.pm	(original)
+++ p5ee/trunk/App-Context/lib/App.pm	Thu May 25 10:48:26 2006
@@ -385,10 +385,20 @@
 sub use {
     &App::sub_entry if ($App::trace);
     my ($self, $class) = @_;
+    no strict;  # allow fiddling with the symbol table
     if (! defined $used{$class}) {
         # if we try to use() it again, we won't get an exception
         $used{$class} = 1;
-        if ($class =~ /^([A-Za-z0-9_:]+)$/) {
+
+        # I could look for a particular variable like $VERSION,
+        # local (*VERSION) = ${*{"$class\::"}}{VERSION};
+        # print "$class VERSION: ", ${*VERSION{SCALAR}}, "\n";
+
+        # but I decided to look for *any* symbol table entry instead.
+        if (%{*{"$class\::"}}) {  # if any symbols exist in the symbol table
+            # do nothing
+        }
+        elsif ($class =~ /^([A-Za-z0-9_:]+)$/) {
             eval "use $1;";
             if ($@) {
                 App::Exception->throw(
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.