View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Rocky Bernstein > Devel-Callsite-0.06 > Devel::Callsite



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.06   Source   Latest Release: Devel-Callsite-0.10

Devel::Callsite - Get caller return OP address and Perl interpreter context


  use Devel::Callsite;
  my $site = sub { return callsite() };
  printf "OP location: 0x%x\n", $site->(); # prints caller OP location
  printf "OP location: 0x%x\n", $site->(); # prints a different OP location

  print context(), "\n"; # prints the interpreter context, a unsigned number


The callsite() function returns the the OP address of the caller, a number, one level up from where it was called. It's useful for functions that need to uniquely know where they were called, such as Every::every(); see Every. Or it can be used to pinpoint a location with finer granularity than a line number. In conjunction with an OP tree disassembly you can know exactly where the caller is located in the Perl source.

The context() function returns the interpreter context as a number. This is a fairly unique number together with the call site.


Ben Morrow conceived this and posted it to perl5-porters. Ted Zlatanov then turned it into a CPAN module which he maintained for the first 3 revisions.

It is currently maintained (or not) by Rocky Bernstein.


B::Concise to disassemble the OP tree. Devel::Trepan optionally uses Devel::Callsite to show you exactly where you are stopped inside the debugger.


Rocky Bernstein <> (current maintainer) Ted Zlatanov <> Ben Morrow

syntax highlighting: