sub - declare a subroutine, possibly anonymously

- NAME
- SYNOPSIS
- DESCRIPTION

# NAME

sub - declare a subroutine, possibly anonymously

# SYNOPSIS

sub NAME BLOCK

sub NAME (PROTO) BLOCK

sub NAME : ATTRS BLOCK

sub NAME (PROTO) : ATTRS BLOCK

# DESCRIPTION

This is subroutine definition, not a real function per se. Without a BLOCK it's just a forward declaration. Without a NAME, it's an anonymous function declaration, and does actually return a value: the CODE ref of the closure you just created.

See the perlsub manpage and the perlref manpage for details about subroutines and references, and the attributes manpage and the Attribute::Handlers manpage for more information about attributes.

sub - declare a subroutine, possibly anonymously