halley has asked for the wisdom of the Perl Monks concerning the following question:
(In our facility, we have many environment variables which could hint to a script that it's being executed by a developer, and not by a typical end-user. If you have other more general ideas to detect this situation, that's a side question.)
For a wholly-deprecated module, I would just add one line to the top of the module. Then when the top-level script is executed in a developer environment, deprecated::import() would simply carp about how OldeCruft is deprecated. The deprecation is just a warning; no changes are made to the rest of the behavior.
package OldeCruft; use deprecated; # carps if module loaded ...
However, I'd also like to be able to deprecate specific symbols within the crufty namespace, without editing anything else deep in OldeCruft.pm. For example, if OldeCruft::dangerous() is deprecated, then the script should carp about that fact on the FIRST call to that sub.
package OldeCruft; use deprecated qw(dangerous); # carps if OldeCruft::dangerous() is called ...
Is there a straightforward and robust way to hook each named deprecated sub with a separate check-and-carp behavior? I'm not too familiar with the way sub names are joined to a symbol hash, and want to know if manipulating that symbol hash is a risky or generally safe proposition.
Update: use deprecated; contains the tested and documented implementation, from Aristotle's suggestions.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use deprecated;
by broquaint (Abbot) on Nov 26, 2003 at 15:36 UTC | |
|
Re: use deprecated;
by liz (Monsignor) on Nov 26, 2003 at 14:53 UTC | |
by halley (Prior) on Nov 26, 2003 at 15:16 UTC | |
|
Re: use deprecated;
by danger (Priest) on Nov 26, 2003 at 14:58 UTC | |
|
Re: use deprecated; (Eiffel's obsolete)
by grinder (Bishop) on Nov 26, 2003 at 15:21 UTC | |
by liz (Monsignor) on Nov 26, 2003 at 16:30 UTC | |
by halley (Prior) on Nov 26, 2003 at 15:29 UTC | |
by revdiablo (Prior) on Nov 26, 2003 at 17:31 UTC | |
|
Re: use deprecated;
by Aristotle (Chancellor) on Nov 26, 2003 at 17:53 UTC | |
by adrianh (Chancellor) on Nov 26, 2003 at 23:55 UTC | |
by Aristotle (Chancellor) on Nov 28, 2003 at 01:18 UTC | |
by adrianh (Chancellor) on Dec 03, 2003 at 01:21 UTC | |
|
Re: use deprecated;
by halley (Prior) on Nov 26, 2003 at 14:47 UTC | |
by ysth (Canon) on Nov 27, 2003 at 04:38 UTC | |
|
Re: use deprecated;
by linux454 (Pilgrim) on Nov 28, 2003 at 15:23 UTC |