>>>>> "TM" == Tom Metro <[email protected]> writes:
TM> I have some code with an anonymous sub that uses __ANON__ to set the sub
TM> name in logging and error messages (a semi-documented trick) like:
TM> sub {
TM> local *__ANON__ = "subname"; # name the anon sub
TM> [...]
TM> warn *__ANON__,": ...\n";
TM> The problem comes about with the warn call that wants to reference
TM> __ANON__. If __ANON__ is used by itself, it produces a bareword warning.
TM> If it is used as a glob (either *__ANON__ or *{__ANON__}), it works, but
TM> produces output prefixed with "*", which seems to suggest it isn't
TM> really being interpreted as a glob.
a couple of quick ideas which may be off target.
try
local *__ANON__ = \"subname" ;
warn "$__ANON__, ...\n" ;
that only sets the scalar slot of the glob so you could access it as a
scalar. you may just be able to do the second line change and access the
scalar and not the whole glob.
why do you think you need a glob there at all? why not use a scalar and
make it a closure since you seem to access the name from within the same
sub? it may work with setting the lexical scalar from the surrounding
sub or even from inside (then it isn't a closure). if you need dynamic
scoping then the local scalar without a glob may work.
uri
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm