Subroutine Attributes

Attribute Function
lvalue Subroutine can be target of assignment.
locked Perl ensures lock is acquired on subroutine itself before subroutine is entered. Can only be used by single thread at a time.
method Prevents "Ambiguous call resolved as CORE::%s" warning.
locked method Perl acquires lock on first argument (object) and method before execution.


sub

Named declarations:

    sub NAME PROTO ATTRS
    sub NAME ATTRS
    sub NAME PROTO
    sub NAME
  

Named definitions:

    sub NAME PROTO ATTRS BLOCK
    sub NAME ATTRS BLOCK
    sub NAME PROTO BLOCK
    sub NAME BLOCK
  

Examples

    sub be_careful : locked method {
      my $self = shift();
      # Single entry operation here
    }

    my $population = 0;
    sub population : lvalue {
      $population;
    }

    population ++;  # Should increment $population