Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Safe::Caller
A nicer interface to the built-in caller

Safe::Caller - A nicer interface to the built-in caller


NAME

Safe::Caller - A nicer interface to the built-in caller()


SYNOPSIS


 package abc;

 use Safe::Caller;

 $caller = Safe::Caller->new;

 a();

 sub a { b() }

 sub b {

     print $caller->{subroutine}->();

     if ($caller->called_from_subroutine('abc::a')) { # do stuff }

 }


DESCRIPTION


CONSTRUCTOR

new


 $caller = Safe::Caller->new(1);

Supplying how many frames to go back while running perlfunc/caller is optional. By default (if no suitable value is supplied) 1 will be assumed. The default will be shared among all method calls (accessors & verification routines); the accessors may optionally accept a frame as parameter, whereas verification routines (called_from_*()) don't.


METHODS

Accessors


 $caller->{package}->();

 $caller->{filename}->();

 $caller->{line}->();

 $caller->{subroutine}->();

 $caller->{hasargs}->();

 $caller->{wantarray}->();

 $caller->{evaltext}->();

 $caller->{is_require}->();

 $caller->{hints}->();

 $caller->{bitmask}->();

See perlfunc/caller for the values they are supposed to return.

called_from_package

Checks whether the current sub was called within the appropriate package.


 $caller->called_from_package('main');

Returns 1 on success, 0 on failure.

called_from_filename

Checks whether the current sub was called within the appropriate filename.


 $caller->called_from_filename('foobar.pl');

Returns 1 on success, 0 on failure.

called_from_line

Checks whether the current sub was called on the appropriate line.


 $caller->called_from_line(13);

Returns 1 on success, 0 on failure.

called_from_subroutine

Checks whether the current sub was called by the appropriate subroutine.


 $caller->called_from_subroutine('foo');

Returns 1 on success, 0 on failure.


SEE ALSO

perlfunc/caller, the Perl6::Caller manpage, the Devel::Caller manpage, the Sub::Caller manpage


AUTHOR

Steven Schubiger <schubiger@cpan.org>


LICENSE

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy