Attributes is a convenient way to add additional semantics (meaning) to a subroutine or variable.
For instance if you wanted to add function signatures to Perl subroutines you could do something like this.
#subroutinge must always be called with to args:
#a username and a password
sub login_user : Signature( username, password ) {
#do something to login a user.
}
At compile-time the subroutine Signature will be automatically called. This subroutine could basically do anything, but in the example it would probably parse the function signature and if it is valid, manipulate the symbol table by insertering a subrouting that does argument validation before calling login_user in place of the original login_user subroutine.
A more thorough explanation of how to use attributes can be found here
|