http://qs321.pair.com?node_id=561884


in reply to Re: Multi-line comments in perl code?
in thread Multi-line comments in perl code?

Emacs also has a "ESC x comment-region" command (which I have bound to a key, myself). Select the block of multi-line text, do a comment-region, and in cperl-mode, "# " will magically appear in front of every line. If you do a "C-u" prefix first, you can use the same command to remove the commenting.

Alternately, it's not at all difficult to write keystroke macros that do things like "insert a '#' in front of this line and then move down one line", which you can loop to comment a series of lines.

The default keystrokes for that (Off the top of my head, and untested):

Defining the macro:

C-x ( C-a # C-n C-x )
Running it once:

C-x e
Running it 10 times:

C-u 10 C-x e

My personal preference: don't use one of the workarounds. Everyone understands "#" commented lines, but many will find your workaround confusing. Optimize for readability, not for ease of typing.

But if you do use a workaround, my preference would be for abusing pod ('=for comment/=cut'), which is endorsed by Damien Conway in "Perl Best Practices".