Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Named evals? (Sub::Name)

by lodin (Hermit)
on Feb 01, 2008 at 12:08 UTC ( [id://665553]=note: print w/replies, xml ) Need Help??


in reply to Named evals?

You can also name the subroutine by using Sub::Name:

use Carp; use Sub::Name; subname( my_anonymous_sub => sub { croak("Whee!"); } )->(); __END__ Whee! at - line 6 main::my_anonymous_sub() called at - line 8
The benefit of this is that you don't name all anonymous subroutines that are called inside this anonymous subroutine.
use Carp; use Sub::Name; subname( my_anonymous_sub => sub { sub { carp("subname"); }->() } )->(); sub { local *__ANON__ = 'my_anonymous_sub'; sub { carp("*__ANON__"); }->() }->(); __END__ subname at - line 7 main::__ANON__() called at - line 8 main::my_anonymous_sub() called at - line 10 *__ANON__ at - line 15 main::my_anonymous_sub() called at - line 16 main::my_anonymous_sub() called at - line 17

lodin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found