tetsunosukeのnotebook

tetsunosukeのメモです

perlのブロック化コメント

よく忘れるシリーズ。

C言語とかJavaScriptの場合

/*
  ここからコメント
  複数行コメント
*/

みたいなことができます。

しかしPerlの場合は

#comment

というような一行のコメントしかできません。

ところが

How can I comment out a large block of perl code? You can use embedded POD to discard it. Enclose the blocks you want to comment out in POD markers, for example "=for nobody" and "=cut" (which marks ends of POD blocks).

    # program is here
    =for nobody
    all of this stuff
    here will be ignored
    by everyone
    =cut
    # program continue

The pod directives cannot go just anywhere. You must put a pod directive where the parser is expecting a new statement, not just in the middle of an expression or some other arbitrary grammar production. See perlpod for more details.

ってことで、この記号(つまりのPerlDOcの、POD形式)を使って書いてやると、擬似的にコメントが使えるということだ。これは便利。むしろ必須。