1. 程式人生 > >Perl中的單行註釋和多行註釋

Perl中的單行註釋和多行註釋

同其他大多數程式語言一樣,Perl中的單行註釋也是#開頭,例如:

#print "Hello,World!";

但多行註釋,不同的語言有不同的註釋方式,比如說:

Java,C/C++

/*  *註釋若干行  *註釋若干行  *註釋若干行
*/

Python:

"""  用三個雙引號,多行註釋  用三個雙引號,多行註釋  用三個雙引號,多行註釋 """ '''  用三個單引號,多行註釋  用三個單引號,多行註釋  用三個單引號,多行註釋 '''

Ruby:

=begin

This is a comment.
This is a comment, too.
This is a comment, too.

=end

Shell:

# This is a comment.
# This is a comment, too.
# This is a comment, too.

Perl: 多行註釋為:

=  多行註釋內容  多行註釋內容  多行註釋內容 =cut

說明:第一個等號必須緊跟一個字元!

比如說:

#! C:\Perl\bin\perl -w
use strict;
use warnings;
use String::Util ':all';
use 5.016;

=my $element = " abc		 ";
printf "<%s>\n", trim($element);
printf "<%s>\n", trim($element, right => 0);
printf "<%s>\n", trim($element, left  => 0);
=cut