1Perl6::Caller(3)      User Contributed Perl Documentation     Perl6::Caller(3)
2
3
4

NAME

6       Perl6::Caller - OO "caller()" interface
7

VERSION

9       Version 0.04
10

SYNOPSIS

12        use Perl6::Caller;
13
14        my $sub         = caller->subroutine;
15        my $line_number = caller->line;
16        my $is_require  = caller(3)->is_require;
17

EXPORT

"caller"

20        # standard usage
21        print "In ",           caller->subroutine,
22              " called from ", caller->file,
23              " line ",        caller->line;
24
25        # get a caller object
26        my $caller = caller;
27        my $caller = caller();   # same thing
28
29        # get a caller object for a different stack from
30        my $caller = caller(2);  # two stack frames up
31        print $caller->package;  # prints the package name
32
33        # enjoy the original flavor
34        my @caller = caller;     # original caller behavior
35        print $caller[0],        # prints the package name
36

DESCRIPTION

38       This module is experimental.  It's also alpha.  Bug reports and patches
39       welcome.
40
41       By default, this module exports the "caller" function.   This
42       automatically returns a new "caller" object.  An optional argument
43       specifies how many stack frames back to skip, just like the
44       "CORE::caller" function.  This lets you do things like this:
45
46        print "In ",           caller->subroutine,
47              " called from ", caller->file,
48              " line ",        caller->line;
49
50       If you do not wish the "caller" function imported, specify an empty
51       import list and instantiate a new "Perl6::Caller" object.
52
53        use Perl6::Caller ();
54        my $caller = Perl6::Caller->new;
55        print $caller->line;
56
57       Note:  if the results from the module seem strange, please read
58       perldoc -s caller carefully.  It has stranger behavior than you might
59       be aware.
60

METHODS

62       The following methods are available on the "caller" object.  They
63       return the same values as documented in perldoc -f caller.
64
65       There are no "hints" and "bitmask" methods because those are documented
66       as for internal use only.
67
68       ·   "package"
69
70       ·   "filename"
71
72       ·   "line"
73
74       ·   "subroutine"
75
76       ·   "hasargs"
77
78       ·   "wantarray"
79
80       ·   "evaltext"
81
82       ·   "is_require"
83
84       Note that each of these values will report correctly for when the
85       caller object was created.  For example, the following will probably
86       print different line numbers:
87
88        print caller->line;
89        foo();
90        sub foo {
91           print caller->line;
92        }
93
94       However, the following will print the same line numbers:
95
96        my $caller = Perl6::Caller->new;   # everything is relative to here
97        print $caller->line;
98        foo($caller);
99        sub foo {
100           my $caller = shift;
101           print $caller->line;
102        }
103

CAVEATS

105       Most of the time, this package should just work and not interfere with
106       anything else.
107
108       ·   $hints, $bitmask
109
110           'hints' and 'bitmask' are not available.  They are documented to be
111           for internal use only and should not be relied upon.  Further, the
112           bitmask caused strange test failures, so I opted not to include
113           them.
114
115       ·   Subclassing
116
117           Don't.
118
119       ·   Perl 6
120
121           I'm not entirely comfortable with the namespace.  The Perl 6 caller
122           actually does considerably more, but for me to have a hope of
123           working that in, I need proper introspection and I don't have that.
124           Thus, I've settled for simply having a caller object.
125
126       ·   *CORE::GLOBAL::caller
127
128           I didn't implement this, though I was tempted.  It turns out to be
129           a bit tricky in spots and I'm very concerned about globally
130           overriding behavior.  I might change my mind in the future if
131           there's enough demand.
132
133       ·   Overloading
134
135           In string context, this returns the package name.  This is to
136           support the original "caller" behavior.
137
138       ·   List Context
139
140           In list context, we simply default to the original behavior of
141           "CORE::caller".  However, this always assumes we've called caller
142           with an argument.  Calling "caller" and caller(0) are identical
143           with this module.  It's difficult to avoid since the stack frame
144           changes.
145

AUTHOR

147       Curtis "Ovid" Poe, "<ovid@cpan.org>"
148

ACKNOWLEDGEMENTS

150       Thanks to "phaylon" for helping me revisit a bad design issue with
151       this.
152

BUGS

154       Please report any bugs or feature requests to
155       "bug-perl6-caller@rt.cpan.org", or through the web interface at
156       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl6-Caller>.  I will
157       be notified, and then you'll automatically be notified of progress on
158       your bug as I make changes.
159

ACKNOWLEDGEMENTS

162       Copyright 2007 Curtis "Ovid" Poe, all rights reserved.
163
164       This program is free software; you can redistribute it and/or modify it
165       under the same terms as Perl itself.
166
167
168
169perl v5.28.1                      2019-02-02                  Perl6::Caller(3)
Impressum