Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > import conundrum

Reply
Thread Tools

import conundrum

 
 
kj
Guest
Posts: n/a
 
      03-29-2007



According to the documentation for "use", if one wants to prevent
a module's import from being called when the module is use'd, one
is supposed pass an empty list as the second argument to "use":

use Foo::Bar ();

But now suppose that Foo::Bar in turn use's some other module Foo:

################################################## ##########
# Foo/Bar.pm
package Foo::Bar;
use Foo;

# yadda-yadda

1;
__END__
################################################## ##########

and, furthermore, suppose that Foo *has* an import method:

################################################## ##########
# Foo.pm
package Foo;

sub import {
shift->go_nuts( @_ );
}

# yadda-yadda

1;
__END__
################################################## ##########

In this case, even if the user loads Foo/Bar.pm with "use Foo::Bar
()", Foo::import is still invoked.

My problem is this: how to give the users of Foo::Bar the opportunity
to veto the calling of Foo::import? The only approach I can think
of is to define a Foo::Bar::import method whose only function is
to call Foo::import, and change the line "use Foo" to "use Foo ()":

################################################## ##########
# Bar/Foo.pm
package Foo::Bar;

use Foo ();

sub import {
shift;
Foo->import( @_ );
}

# yadda-yadda

1;
__END__
################################################## ##########

This does indeed have the effect of "transmitting" the "()" argument
from "use Foo::Bar ()" through to Foo. But in a suite of modules
of any complexity this approach quickly becomes cumbersome.

Is there any other for Foo to know that it has been use'd by a
module that *itself* was use'd with a "()" argument?

TIA!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex Custom Control Conundrum Iain ASP .Net 0 02-17-2006 08:38 PM
Conundrum with package name in "dynamic" static factory method Nobody Java 6 07-14-2005 04:50 PM
Provider MPLS IP-Enabled Frame Relay Cloud Routing Conundrum Scott Cisco 0 12-23-2004 02:13 AM
Bookmark Filing Conundrum mapmaker Firefox 2 12-21-2004 03:22 AM
Clunky Cache Code Conundrum? Jim Owen ASP .Net 4 07-03-2003 04:49 PM



Advertisments