What does the colon mean in the following Perl program?
MAIN: {
print "Hello\n";
}
Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames - Use double colon (::) to separate package name components instead of single quotes (').
!~ is the negation of the binding operator =~ , like != is the negation of the operator == . The expression $foo !~ /bar/ is equivalent, but more concise, and sometimes more expressive, than the expression !($foo =~ /bar/)
It's an operator. Specifically, the readline operator. There's a reference to it as the "angle operator" in perlvar, although there isn't actually any such operator.
$$ The process number of the perl running this script. (Mnemonic: same as shells.) $? The status returned by the last pipe close, backtick (\`\`) command or system operator.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With