I don't grok Perl subroutine attributes at all.
I have never seen them in actual code and perldoc perlsub
and the perldoc attributes
fail to answer my questions:
- What are attributes useful for?
- What do they bring to the table that is not already present in Perl best practices?
- Are there any CPAN modules (well-known or otherwise) that make use of attributes?
It would be great if someone could put together a detailed example of attributes being used the way they should be.
For those who are as clueless as me, attributes are the parameters after the colon in the attributes SYNOPSIS
examples below:
sub foo : method ;
my ($x,@y,%z) : Bent = 1;
my $s = sub : method { ... };
use attributes (); # optional, to get subroutine declarations
my @attrlist = attributes::get(\&foo);
use attributes 'get'; # import the attributes::get subroutine
my @attrlist = get \&foo;
mod_perl
uses attributes to differentiate method and non-method handlers. – Atombomb