in reply to sub getting reference to itself : generic way

calin,
I am completely out of my element here, but does Devel::Caller (advertised as meatier) or any of the other CPAN related modules fit the bill?

Cheers - L~R

  • Comment on Re: sub getting reference to itself : generic way

Replies are listed 'Best First'.
Re^2: sub getting reference to itself : generic way
by calin (Deacon) on Jun 18, 2004 at 16:53 UTC

    Yep, it seems to do (though it's not built-in OR standard). Untested:

    use Devel::Caller 'caller_cv'; sub foo { my $selfref = caller_cv(0); # ... }
Re^2: sub getting reference to itself : generic way
by Joost (Canon) on Jun 18, 2004 at 16:53 UTC
      Joost,
      *Chuckle* - I will share a snippet of the CB conversation I had along those lines:
      • Corion Seems like calin wants something like caller(-1) ... I wonder more about caller(-2) though - now that would be a feature of Perl to make other languages envious :-)
      • Limbic~Region was just reading that Corion
      • Corion Hmm - no, caller(0) does almost everything calin wants, except that it only returns a name not a reference ... But why should caller be restricted to non-negative numbers ? :-))))
      • Limbic~Region *shrug* - I am betting someone comes up with a B:: solution or something though the question looked to be asking for something generic
      • Limbic~Region does Devel::Caller fill in the missing code ref?
      • Corion Limbic~Region++ indeed!
      • Zaxo suspects diotalevi will come up with something clever and wicked
      Note: Quotes used with permission

      Cheers - L~R