PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, June 29, 2022

[FIXED] What are the common workarounds for multi-line comments in Perl?

 June 29, 2022     comments, perl     No comments   

Issue

This RFC mentions

Unlike many programming languages Perl does not currently implement true multiline comments. This, and the workarounds that are in common use can be problematic. This could be solved by adding a new syntax to allow for comments to span more than one line, like the variation on here-documentation cited below.

What are the common workarounds?

Two techniques I found here are

if (0) {
  <comment>
}

and

=pod
<comment>
=cut

Are these safe to use? Are there others that work better?


Solution

The downside of the "if" solution is that the commented out code still has to be compiled (and therefore still has to be syntax checked).

The downside of your pod solution is that your comments will appear in any documentation generated from the pod.

I use a version of the pod solution that doesn't have that problem. Pod supports =begin format ... =end format paragraphs that are handled by specific formatters. I just invent a "comment" format that isn't handled by any of the formatters I use.

#!/usr/bin/perl

print "This line is executed\n";

=begin comment

print "This line isn't\n";

=end comment

=cut

print "This line is\n";


Answered By - Dave Cross
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing