|Don't ask to ask, just ask|
lazily getting around an Exporter problemby meraxes (Friar)
|on Oct 04, 2007 at 19:46 UTC||Need Help??|
meraxes has asked for the
wisdom of the Perl Monks concerning the following question:
Esteemed monks, I'm hoping someone can help me.
BOOM! It took me a while to realize the problem here. Params::Validate is importing SCALAR, ARRAYREF and HASHREF tags into the current namespace.... and oh look, Contextual::Return uses those as well! ARG!
Now, I know what I can use the full package name with Params::Validate to get the various "type" validators and not import them like so:
but I'd have to go through all the modules and fix all the use statements and expand out the type checks to Params::Validate::ARRAYREF/SCALAR/HASHREF. I might even be able to automate something to do it for me... but that scares me. It's all over the place!
Now, the easy thing would be to do the same with Contextual::Return but I realized my Perl-fu is not as strong as TheDamian's (stunning realization, I know). It doesn't play well like that and from what I can see in the source (yes, you may laugh now at a very average Perl hacker trying to understand Damian's code) there's a whole lot going on that makes just specifying out the full package name a non-option (I've tried). So that means this doesn't work:
So, I HAVE a solution, but it seems a bit of a pain to have to go through ALL the code and change every use of Params::Validate in bunches of files so I can use Contextual::Return in one place. Can anyone help me be lazy? I really don't know how else I can stop these two modules from clashing.
Well... maybe I'll ask Rolsky and Damian to arm wrestle for the namespace. :D
Thanks for the assistance.
Updatery: fixed wrong module name in code
Updatery the Second: fixed missing bracket.