Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: More than One Line Comment

by tphyahoo (Vicar)
on Nov 17, 2005 at 11:24 UTC ( [id://509362]=note: print w/replies, xml ) Need Help??


in reply to More than One Line Comment

A gotcha that got me for pod style comments such as
=for comment blah =cut
The =for and =cut MUST GO AT THE BEGINNING OF THE LINE.

YOU CANNOT INDENT THEM.

The lack of sand multi-line commenting (sane = something like most other languages have) is one of my major pet peeves with perl. Personally I usually just use #. I am thinking of trying out Roy Johnson's idea of 0 and do type comments. And... I don't like pod-style comments, largely because they're unindentable and mess up my pretty use of whitespace. Yuck.

Replies are listed 'Best First'.
Re^2: More than One Line Comment
by ff (Hermit) on Nov 17, 2005 at 15:40 UTC
    I'd say "can't indent them" is a feature.

    Be definition, we are talking about cases of multiline comments, and such a chunk deserves easily identifiable start/stop markers. On their own lines. And of course everything between the markers gets to stay exactly where it was before you marked it off. Later, if you decide that you can live with those lines running after all (as below), you can put '#' comments in front of your pod markers; don't delete your pod markers because you may change your mind yet again and desire to re-ignore those lines.

    #=pod #no warnings 'all'; # doesn't seem to prevent error message +s.... my $xform = new RTF::TEXT::Converter->new( output => \$output_string ); $xform->parse_string( $input_string ); #=cut
    But a "good style" rule somewhere says "Don't abuse pod this way!" Well, I don't put my user documentation for the program within the file, I put it in it's own separate pod file, and so the two usages never get mixed up.

    I also use the 'if 0' approach to isolate code blocks that I don't want to run. Particularly for code blocks that help me with debugging. By formatting them as follows, i.e. with 'if 1' starting in column 1 when I want a debugging section to fire, I can find those sections easily via vim with '/^if 1' and turn them off by editing to 'if 0'. While I could also use a "$debug" flag, I'd then have to wade through all the other debugging output from the other 'if $debug' sections when I really only want the surgical strike of enabling this particular block. The problem with using 'if 0' to comment out questionable/narrative sections of stuff is that the compiler complains about improper innards even though you don't want any of it to run.

    do { # Should be unnecessary to see this; the data is in the dd_config_ +info file my $msg = Dumper( \%ddcon_contents, \@ddcon_order, $dd_con_defaults, ); esdw "ddc_data2 $msg\n"; } if 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://509362]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-03-29 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found