in reply to Re^2: Questions about sharing code
in thread Questions about sharing code
As for the difference between the first and the third, you need to seriously look at maintenance for the answer. For all the code in a given file, you can do a search for "sub foo" and find out what foo does. But, if it's a subroutine from another module, you can't easily find it. If there's just one Mycommonroutines, then you know where it is. But, what if there are 2? 5? 10? It gets a little hairier.
It is for this reason that I and other CPAN authors have started using the following meme:
# Explicitly state nothing will be imported use Scalar::Util (); # Call the function with the complete name Scalar::Util::weaken( $some_ref );
For functions like weaken(), this may seem like overkill. But, this kind of habit will help maintainers because it becomes a flag to say "I didn't write this code in this file and this is where you can find it." And, conversely, if it doesn't have a prepended location, then it must be in this file somewhere. Any kind of hint like that will help your maintainer. Remember - code as if the guy who sees you code after you knows where you live and likes to swing axes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Questions about sharing code (@EXPORT_OK++)
by tye (Sage) on Nov 28, 2007 at 17:28 UTC | |
by dragonchild (Archbishop) on Nov 28, 2007 at 17:42 UTC | |
by tye (Sage) on Nov 28, 2007 at 17:54 UTC | |
by bradcathey (Prior) on Nov 28, 2007 at 17:48 UTC |