use B; sub codename { my $coderef = shift; return unless ref $coderef eq 'CODE'; my $cv = B::svref_2object($coderef); return $cv->GV->NAME; }