hcs42
hcs42

Reputation: 13706

What does colon mean in Perl?

What does the colon mean in the following Perl program?

MAIN: {
    print "Hello\n";
}

Upvotes: 7

Views: 5079

Answers (2)

DVK
DVK

Reputation: 129383

The colon is a required separator of a label from the following block.

From perlsyn:

The LABEL is optional, and if present, consists of an identifier followed by a colon

Upvotes: 11

JB.
JB.

Reputation: 42094

It separates a label (MAIN) from a block (the stuff between curly braces).

In Perl, a label is always suffixed with a colon, so you might argue the colon is part of the label.

Upvotes: 17

Related Questions