You seem to be asking for introspection . There are many OO frameworks that provide it (e.g. Moose ). But, if you want to be able to declare a function and then examine it from your program, Function :: Parameters is the smart way.
From Function :: Parameters :: Info Summary:
use Function::Parameters; fun foo($x, $y, :$hello, :$world = undef) {} my $info = Function::Parameters::info \&foo; my $p0 = $info->invocant;
The introspection function in the :: Info module is actually implemented using Moose.
source share