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

Re^6: Runtime introspection: What good is it?

by lodin (Hermit)
on Jul 08, 2008 at 19:35 UTC ( [id://696303]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Runtime introspection: What good is it?
in thread Runtime introspection: What good is it?

For your own code you can use attributes (experimental feature) to signal what's a method and what's not.

sub foo :method { my $self = shift; # ... return; } sub bar { # ... return; } use attributes; sub is_a_method { scalar grep $_ eq 'method', attributes::get($_[0]); } for ([ foo => \&foo ], [ bar => \&bar ]) { print "$_->[0] is a " . (is_a_method($_->[1]) ? 'method' : 'function +') . "\n"; } __END__ foo is a method bar is a function

lodin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found