NAME

Sub::Called - get information about how the subroutine is called

VERSION

Version 0.01

SYNOPSIS

use Sub::Called;

sub test {
    if( Sub::Called::with_ampersand() ){
        print "you called this subroutine this way: &test\n",
              "note that this disables prototypes!\n";
    }
}

EXPORTS

There are no subroutines exported by default, but you can export all subroutines explicitly

use Sub::Called qw(with_ampersand);

FUNCTIONS

with_ampersand

LIMITATIONS / TODO

There are limitations and I don't know if I can solve these "problems". So this section is also named "TODO". If you know a solution for any of these limitations, please let me know.

Subroutine References

It seems that there are some problems with subroutine references.

This may not work:

sub test2 {
    if( Sub::Called::with_ampersand() ){
        die "die hard";
    }
};
  
my $sub2 = main->can( 'test2' );
&$sub2();

Inside a module

If you call subroutines in a module but outside any subroutine (so the subroutine calls are executed when the module is loaded), I cannot give a correct answer ;-)

package Check;

use strict;
use warnings;
use Sub::Called qw(with_ampersand);

&test;

sub test {
    if( with_ampersand() ){
        print "yada yada yada\n";
    }
}

AUTHOR

Renee Baecker, <module at renee-baecker.de>

BUGS

Please report any bugs or feature requests to bug-sub-called at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Called. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Sub::Called

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Renee Baecker, all rights reserved.

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