djihed has asked for the wisdom of the Perl Monks concerning the following question:
-arg specifies the name of a resource to load at import time with some default values. I'd like foo to die if the resources cannot be loaded from the default values. The conflict arises because the user has the option to use "use" or "require". Suppose that foo() will die on default values:package Mod; use... { foo(); } sub import { my ($pkg, %options) = @_; __PACKAGE__->foo(arg => $options{-arg}); }
How to resolve this?require Mod; # dies, good. use Mod; # dies, good. use Mod -arg => 'custom'; # dies, BAD.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use, require, import and use arguments
by jethro (Monsignor) on Feb 25, 2011 at 17:32 UTC | |
by djihed (Novice) on Feb 26, 2011 at 12:59 UTC | |
by Anonymous Monk on Feb 26, 2011 at 14:06 UTC | |
by djihed (Novice) on Feb 26, 2011 at 15:16 UTC | |
by Anonymous Monk on Feb 26, 2011 at 15:28 UTC |