[Dub-pm] Tip of the day: Multi-line commenting

Dave O Connor doc at redbrick.dcu.ie
Wed Apr 14 06:52:09 CDT 2004


This comes from Dave Cross on c.l.p.m, on a discussion of multi-line
commenting.

Perosnally, I think perl should have something like q() except for comments,
partly because it's annoying to have to either prepaend lines withhashes, or
use POD, like in today's tip.

If you need to comment out a block of perl code temporarily, and don't feel
like adding a pile of hashes at the start of each line, you can use the POD
=for directive, which tells POD  this POD section is not 'for' its
documentation (thus not breaking your POD documentation), and also tells perl
to ignore the section until the =cut

e.g.

print "This code is executed\n";

=for comment
print "This code is commented out. Blah!\n";
 ... more code here ...
 You can even put barewords here!
=cut

POD docs can then be put in as normal, and this doesn't interfere, unlike if
you just used =item and =cut, or =pod and =cut. (Which I used to do until this
morning :))

Here's an exercise for the reader (since my vim skillz suck): What's an easy
way to prepend a hash to a block of selected text?

	- DoC



More information about the Dublin-pm mailing list