perlquestion Daryn Greetings gentle monks, </p>is there a magic way to call an anonymous subroutine within its own body without binding it to a coderef ? </p>I'd like to do something like that: <code> (sub {... magic(...) ... )->(args) </code> where <code>magic</code> would refer to the anonymous sub being defined. </p>The closest I came so far was <code> use strict; { my $coderef; ($coderef = sub { ... $coderef->(...) ...)->(args); } </code> which strikes me as inelegant and potentially leaky. Here is some runnable (if silly) code : <code> use strict; # direct call of unbound non recursive anonymous subroutine my $res = (sub{ print @_[0] + @_[1] . "\n\n";})->(100,1); # need to bind to a coderef if recursive ? { my $coderef; ($coderef = sub {return unless $_[0] > 0; print "$_[0]\n"; $coderef->($_[0]-1)})->(4); } </code> </p>In real life, I sometimes need to call a recursive function or subroutine to process a tree-like structure. It gets called only once, at a specific point, and should (IMO) not need to be graced with a name or bound to a coderef (much in the spirit of a <code>map {...} @somearray</code>). </p>Any thoughts ? TIA.