NAME
Sub::Attribute - Reliable subroutine attribute handlers
VERSION
This document describes Sub::Attribute version 0.05.
SYNOPSIS
package
Attribute::Foo;
use
Sub::Attribute;
sub
Foo :ATTR_SUB{
my
(
$class
,
$sym_ref
,
$code_ref
,
$attr_name
,
$attr_data
) =
@_
;
# ...
}
# and later
package
main;
sub
something :Foo(xyzzy){
# ...
}
# apply: __PACKAGE__->Foo(\*something, \&something, 'Foo', 'xyzzy')
DESCRIPTION
Sub::Attribute
is a role to define attribute handlers for specific subroutine attributes.
The feature of this module is similar to that of Attribute::Handlers
, but has less functionality and more reliability. That is, while Attribute::Handlers
provides many options for ATTR(CODE)
, Sub::Attribute
provides no options for ATTR_SUB
. However, the attribute handlers defined by Sub::Attribute
are always called with informative arguments. Attribute::Handlers
's ATTR(CODE)
is not called in run-time eval()
, so ATTR(CODE)
is not reliable.
INTERFACE
The ATTR_SUB meta attribute
Defines a method as an subroutine attribute handler.
CONFIGURATION AND ENVIRONMENT
$ENV{SUB_ATTRIBUTE_DEBUG}
If true, reports how attributes are applied, using warn()
function.
DEPENDENCIES
Perl 5.8.1 or later, and a C compiler.
BUGS
No bugs have been reported.
Please report any bugs or feature requests to the author.
SEE ALSO
"Subroutine Attributes" in perlsub.
AUTHOR
Goro Fuji (gfx) <gfuji(at)cpan.org>.
LICENSE AND COPYRIGHT
Copyright (c) 2009-20010, Goro Fuji (gfx). Some rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.