Comments
Study what comments are and how we should write them.
We'll cover the following
We need to add comments in our code to make it more readable for the reader. Comments in Perl are of two types:
- Single line comment
- Multiline comment
Single line comment
If our comment can fit on a single line, then we can use a #
symbol.
# this is a single line commentprint "Hello World"; # This line prints Hello World
Explanation
We use the #
symbol for a single line comment. We can use multiple instances of #
symbols in our code to comment on multiple single lines.
Multiline comment
If there is a paragraph or functionality which takes more than one line explanation then we can use a multiline comment which starts with =
(followed by some text ) and ends with =cut
.
=PODthisis amultilinecomment=cut
Explanation
A multiline comment starts with =(text)
sign and ends with =cut
keyword. You can write anything between these lines and it will not be executed.
It is a common convention to start a multiline comment with
=POD
and end at=cut