Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: recursive anonymous subroutines

by chromatic (Archbishop)
on Apr 06, 2006 at 20:01 UTC ( #541712=note: print w/ replies, xml ) Need Help??


in reply to recursive anonymous subroutines

No.

(Now if you had asked how to get a reference to the current subroutine, even if it's anonymous and without modifying the external code, there are ways to do that.)


Comment on Re: recursive anonymous subroutines
Re^2: recursive anonymous subroutines
by ikegami (Pope) on Apr 06, 2006 at 20:05 UTC
    How would one do that? I'm curious.
      OK, I found a way, but you won't like it! :-)
      Use $DB::sub->() but you have to run it under the perl debuger (perl -d):
      sub { print 'A'; $DB::sub->() }->();

      Ted Young

      ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

        That only works when the debugger is enabled. For general use, see Devel::Caller.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      I'd write a little very scary, very hairy XS code. I don't know which of three or four approaches would work best, but I'd start by poking around PL_curcop.

        Surely the *best* approach is to not write the scary hairy XS code and just accept that you'll have to use a variable. It's not like variables kill babies or anything.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2014-09-20 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (152 votes), past polls