I do not think that means what you think that means. :)<br><br>Can I ask why you're doing "use base qw(Net::DBus::Object);" as opposed to "use Net::DBus::Object;" ? The 'use base' is nonsensical in this context as it's modifying the @ISA array. It's essentially saying "This class is a subclass of Net::DBus::Object" and not actually making any part of Net::DBus::Object available to you. I suspect just doing use Net::DBus::Object and you'll be fine.<br>
<br>Though I'm hardpressed to explain why, using "require" instead of "use" seems to be more canonical when dynamically loading modules. I'm sure someone far smarter than I on this list could explain that. I suspect it's the difference between bareword and string (bareword loads a module, string loads the filename specifically instead of searching %INC for it). There's also import voodoo that won't happen (unless you do the voodoo yourself) but if you're only loading OO modules this shouldn't be a big deal. <br>
<br>D<br>--<br clear="all"><a href="mailto:dave.s.doyle@gmail.com">dave.s.doyle@gmail.com</a><br>
<br><br><div class="gmail_quote">On Wed, Dec 9, 2009 at 9:49 PM, Madison Kelly <span dir="ltr"><<a href="mailto:linux@alteeve.com">linux@alteeve.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi all,<br>
<br>
This may be due to my ignorance, but I am having a problem that I don't *think* I should be.<br>
<br>
I've got a set of methods in my module that loads various other modules wrapped in 'eval's so that I can handle missing modules a little more gracefully. All of these work except one.<br>
<br>
For example; This works:<br>
<br>
-----------------------------------------<br>
# Script<br>
use AN::Tools;<br>
my $an=AN::Tools->new();<br>
$an->_load_net_dbus();<br>
<br>
# Module<br>
sub _load_net_dbus<br>
{<br>
my $self=shift;<br>
<br>
eval 'use Net::DBus;';<br>
if ($@)<br>
{<br>
print "Gak! $@\n";<br>
return (undef);<br>
}<br>
else<br>
{<br>
# Good, record it as loaded.<br>
$self->_net_dbus_loaded(1);<br>
print "Net::DBus loaded.\n";<br>
}<br>
<br>
return (0);<br>
}<br>
-----------------------------------------<br>
<br>
Now though, I've got one that doesn't... The main difference that I can see is the 'use base ...'.<br>
<br>
-----------------------------------------<br>
# Script<br>
$an->_load_net_dbus_object();<br>
<br>
# Module<br>
sub _load_net_dbus_object<br>
{<br>
my $self=shift;<br>
<br>
eval 'use base qw(Net::DBus::Object);';<br>
if ($@)<br>
{<br>
print "Gak! $@\n";<br>
return (undef);<br>
}<br>
else<br>
{<br>
# Good, record it as loaded.<br>
$self->_net_dbus_object_loaded(1);<br>
print "Net::DBus::Object loaded.\n";<br>
}<br>
<br>
return (0);<br>
}<br>
-----------------------------------------<br>
<br>
It *looks* like it loads in that '$@' isn't set. However, when I try to use any of the methods in Net::DBus::Object, it errors.<br>
<br>
Is there something about 'base' that could be messing this up or is it something else? For testing, if I check that the '$an->_load_net_dbus_object();' call returns '0' and then call:<br>
<br>
eval 'use base qw(Net::DBus::Object);';<br>
<br>
From the main script, it does work, so it doesn't seem to be the eval itself that's the problem.<br>
<br>
Thanks all!<br>
<br>
Madi<br>
_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
</blockquote></div><br>