SoFunction
Updated on 2025-04-08

Introduction to the use of single-line comments and multi-line comments in perl

Program comments in Perl: single line comments and multi-line comments

(I) Single line comment:

Lines starting with # are considered comments by perl. But there is an exception. The first line of the perl program starts with #, which specifies the interpreter of the perl program.

For example: #print 1;

This method has a disadvantage, that is, # can only comment one line at a time. If the code to be commented is very long, it is a very troublesome thing.



(2) Multi-line comments:

The most common method is to use POD (Plain Old Documentations) to make multi-line comments. The method is as follows:

=pod
codes to comment
=cut
Note: =pod =cut can only start with = at the beginning of the line and end with =cut. Note: =There is a character immediately after it. =cut is not used later.