Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: comment sections

by Wookie (Beadle)
on Apr 15, 2003 at 11:42 UTC ( [id://250539]=note: print w/replies, xml ) Need Help??


in reply to comment sections

You could simply:
#!/usr/bin/perl -w use strict; # Every job should # Start of comments if (defined undef) { foo... } # End of comments &do_more_stuff();
In terms of efficency - using a constant should kill a large block like that at compile time as opposed to run time (although the optimiser might take away the code in the solution above?).
#!/usr/bin/perl -w use strict; use constant COMMENT_WRAPPER => 0; # Start comments if (COMMENT_WRAPPER) { Blah Blah } # End comments &carry_on_with_stuff();

game(Wookie,opponent) eq 'Wookie' ? undef $problem : remove_limbs(arms,opponent);

Replies are listed 'Best First'.
Re: comment sections
by Abigail-II (Bishop) on Apr 15, 2003 at 11:55 UTC
    But that requires that the stuff you outcomment is actually compilable. And it won't help to outcomment a BEGIN block.

    Abigail

      I vote for using #s as I've stated elsewhere under the heading no pod & code.

      Personally I find the desire or need to temporarily comment out fair sized blocks of code is a warning of impending danger or difficulty. And usually these style of comments are meant to be temporary. Often the trouble is so imminent that it has already arrived.

      Requiring commented code to be compilable seems like a feature to me. But I know what you mean.

      Quick update: The following is not what Abigail said. Abigail pointed out that you can't comment the entire BEGIN block this way. You can't. You can't comment out any other subroutine definition either. Or forward sub declaration.

      And you can comment out code in a begin block. Viz:

      #!/usr/bin/perl use strict; use warnings; BEGIN { use constant COMMENT => 0; } BEGIN { if ( COMMENT ){ print "silence\n"; } print "noise\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2025-03-18 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (56 votes). Check out past polls.