No need for Devel::*
sub t1{ return "t1:",\&t1; } sub t2{ *t2=\&t1 if @_; return "t2:",\&t2; } print t1(), t2(); t1: CODE(0x1bd2940) t2: SCALAR(0x1bd53c8) print t1(), t2(); t1: CODE(0x1bd2940) t2: SCALAR(0x1bd53c8) print t1(), t2(), t2('change it'); Subroutine t2 redefined at (eval 47) line 1, <> line 50. t1: CODE(0x1bd2940) t2: SCALAR(0x1bd53c8) t2: SCALAR(0x1bd53c8) print t1(), t2(); t1: CODE(0x1bd2940) t1: CODE(0x1bd2940)
Update: Or per your example
sub t1{ return "t1:",\&t1; } sub t2{ undef *t2 if @_; return "t2:",\&t2; } print t1(), t2(); t1: CODE(0x1bd5200) t2: CODE(0x1bd5410) print t1(), t2(); t1: CODE(0x1bd5200) t2: CODE(0x1bd5410) print t1(), t2(), t2('change it'); t1: CODE(0x1bd5200) t2: CODE(0x1bd5410) t2: CODE(0x1bd52d8)
Examine what is said, not who speaks.
In reply to Re: Giving subroutines access to themselves
by BrowserUk
in thread Giving subroutines access to themselves
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |