NAME
    Safe::Caller - Control code execution based upon caller()

SYNOPSIS
     package abc;

     use Safe::Caller;

     $caller = Safe::Caller->new;

     a();

     sub a { b() }

     sub b {
         if ($caller->called_from_subroutine('abc::a')) { # do stuff }
         print $caller->{subroutine}->();
     }

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

    Providing how many frames to go back while running perlfunc is optional.
    By default (if no suitable value is provided) 1 will be assumed. The
    default will be shared among all accessors and verification routines;
    the accessors may optionally accept a frame as argument, whereas
    verification routines (`called_from_*()') don't.

METHODS
  called_from_package
    Checks whether the current sub was called within the given package.

     $caller->called_from_package('Package');

    Returns true on success, false on failure.

  called_from_filename
    Checks whether the current sub was called within the given filename.

     $caller->called_from_filename('file');

    Returns true on success, false on failure.

  called_from_line
    Checks whether the current sub was called on the given line.

     $caller->called_from_line(42);

    Returns true on success, false on failure.

  called_from_subroutine
    Checks whether the current sub was called by the given subroutine.

     $caller->called_from_subroutine('Package::sub');

    Returns true on success, false on failure.

ACCESSORS
     $caller->{package}->();
     $caller->{filename}->();
     $caller->{line}->();
     $caller->{subroutine}->();
     $caller->{hasargs}->();
     $caller->{wantarray}->();
     $caller->{evaltext}->();
     $caller->{is_require}->();
     $caller->{hints}->();
     $caller->{bitmask}->();

    See perlfunc for the values they are supposed to return.

SEE ALSO
    perlfunc, Perl6::Caller, Devel::Caller, Sub::Caller

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://dev.perl.org/licenses/

