Comments and POD
Comments are notes for humans that Perl ignores.
In this page:
Comments and POD
A hash sign # starts a comment that runs to the end of the line. Perl has no block comment syntax, but POD (Plain Old Documentation) blocks can be used for longer text: a block starting with a line such as =pod or =begin comment and ending with =cut is skipped by the interpreter. POD is also the standard way to document Perl modules.
Note:
A # inside a quoted string is just a character, not a comment.
Example: Comments and POD
use strict;
use warnings;
# This is a single-line comment
print "Step one\n"; # comment after code
=begin comment
This whole block is ignored by Perl,
so it works like a multi-line comment.
=end comment
=cut
print "Step two # not a comment\n";
# Output:
# Step one
# Step two # not a comment
Login to try C/C++/Java/PHP code in the editor
Common Mistakes
- Expecting C-style /* */ block comments to work
- Forgetting the =cut line that ends a POD block
- Starting POD directives such as =pod anywhere but at the beginning of a line
Chapter Summary
- # starts a comment
- POD blocks can hide multiple lines
- A POD block ends with =cut
- A # inside a string is not a comment
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: