.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Perl6::Caller 3pm" .TH Perl6::Caller 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Perl6::Caller \- OO "caller()" interface .SH "VERSION" .IX Header "VERSION" Version 0.04 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Perl6::Caller; \& \& my $sub = caller\->subroutine; \& my $line_number = caller\->line; \& my $is_require = caller(3)\->is_require; .Ve .SH "EXPORT" .IX Header "EXPORT" .ie n .SH """caller""" .el .SH "\f(CWcaller\fP" .IX Header "caller" .Vb 4 \& # standard usage \& print "In ", caller\->subroutine, \& " called from ", caller\->file, \& " line ", caller\->line; \& \& # get a caller object \& my $caller = caller; \& my $caller = caller(); # same thing \& \& # get a caller object for a different stack from \& my $caller = caller(2); # two stack frames up \& print $caller\->package; # prints the package name \& \& # enjoy the original flavor \& my @caller = caller; # original caller behavior \& print $caller[0], # prints the package name .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is experimental. It's also alpha. Bug reports and patches welcome. .PP By default, this module exports the \f(CW\*(C`caller\*(C'\fR function. This automatically returns a new \f(CW\*(C`caller\*(C'\fR object. An optional argument specifies how many stack frames back to skip, just like the \f(CW\*(C`CORE::caller\*(C'\fR function. This lets you do things like this: .PP .Vb 3 \& print "In ", caller\->subroutine, \& " called from ", caller\->file, \& " line ", caller\->line; .Ve .PP If you do not wish the \f(CW\*(C`caller\*(C'\fR function imported, specify an empty import list and instantiate a new \f(CW\*(C`Perl6::Caller\*(C'\fR object. .PP .Vb 3 \& use Perl6::Caller (); \& my $caller = Perl6::Caller\->new; \& print $caller\->line; .Ve .PP \&\fBNote\fR: if the results from the module seem strange, please read perldoc\ \-s\ caller carefully. It has stranger behavior than you might be aware. .SH "METHODS" .IX Header "METHODS" The following methods are available on the \f(CW\*(C`caller\*(C'\fR object. They return the same values as documented in perldoc\ \-f\ caller. .PP There are no \f(CW\*(C`hints\*(C'\fR and \f(CW\*(C`bitmask\*(C'\fR methods because those are documented as for internal use only. .IP "\(bu" 4 \&\f(CW\*(C`package\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`filename\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`line\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`subroutine\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`hasargs\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`wantarray\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`evaltext\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`is_require\*(C'\fR .PP Note that each of these values will report correctly for when the caller object was created. For example, the following will probably print different line numbers: .PP .Vb 5 \& print caller\->line; \& foo(); \& sub foo { \& print caller\->line; \& } .Ve .PP However, the following will print the \fIsame\fR line numbers: .PP .Vb 7 \& my $caller = Perl6::Caller\->new; # everything is relative to here \& print $caller\->line; \& foo($caller); \& sub foo { \& my $caller = shift; \& print $caller\->line; \& } .Ve .SH "CAVEATS" .IX Header "CAVEATS" Most of the time, this package should \fIjust work\fR and not interfere with anything else. .IP "\(bu" 4 \&\f(CW$hints\fR, \f(CW$bitmask\fR .Sp \&'hints' and 'bitmask' are not available. They are documented to be for internal use only and should not be relied upon. Further, the bitmask caused strange test failures, so I opted not to include them. .IP "\(bu" 4 Subclassing .Sp Don't. .IP "\(bu" 4 Perl 6 .Sp I'm not entirely comfortable with the namespace. The Perl\ 6 caller actually does considerably more, but for me to have a hope of working that in, I need proper introspection and I don't have that. Thus, I've settled for simply having a caller object. .IP "\(bu" 4 \&\f(CW*CORE::GLOBAL::caller\fR .Sp I didn't implement this, though I was tempted. It turns out to be a bit tricky in spots and I'm very concerned about globally overriding behavior. I might change my mind in the future if there's enough demand. .IP "\(bu" 4 Overloading .Sp In string context, this returns the package name. This is to support the original \f(CW\*(C`caller\*(C'\fR behavior. .IP "\(bu" 4 List Context .Sp In list context, we simply default to the original behavior of \&\f(CW\*(C`CORE::caller\*(C'\fR. However, this \fIalways\fR assumes we've called caller with an argument. Calling \f(CW\*(C`caller\*(C'\fR and \f(CWcaller(0)\fR are identical with this module. It's difficult to avoid since the stack frame changes. .SH "AUTHOR" .IX Header "AUTHOR" Curtis \*(L"Ovid\*(R" Poe, \f(CW\*(C`\*(C'\fR .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" Thanks to \f(CW\*(C`phaylon\*(C'\fR for helping me revisit a bad design issue with this. .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-perl6\-caller@rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2007 Curtis \*(L"Ovid\*(R" Poe, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.