Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Commenting out script in Perl like in C++

by moxliukas (Curate)
on Jul 26, 2003 at 10:15 UTC ( #278077=note: print w/replies, xml ) Need Help??

in reply to Commenting out script in Perl like in C++

There are probably three approaches to multiline comments that I can think of at the moment.

  • using POD

    This one is part of the Perl language itself. it is fully documented in perlpod manual. You would do it like this:

    .... some code .... =pod multiline comment (or just code that you don't want to be executed) =cut ...some more code...
  • Working around with if (0) {...}

    This is juat a workaround, where you place the code in a if block that is never executed (you can't put just any text there, because it is Perl code after all). However, you specifically asked for commenting out of Perl code, so this might be applicable to you

    ...some code... if (0) { ...some code commented out... } ...some more code...
  • use ACME::Comment

    There is a module ACME::Comment that let's you use any kind of commenting style you want. This example is taken straight from it's documentation:

    use Acme::Comment type=>'C++', own_line=>1; /* if (ref $mod) { $bar->{do}->blat(msg => 'blarg'); eval { i'm sooo sick of this time for some coffee */ // I prefer beer. --sqrn

Hope this helps.

Replies are listed 'Best First'.
Re: Commenting out script in Perl like in C++
by Abigail-II (Bishop) on Jul 26, 2003 at 16:28 UTC
    If you use if (0), there are a few things you should be aware of. First, the code is still complied - so your outcommented code should be valid, otherwise your program won't compile. Second, things that have a compile time effect still happen. This includes, but is not limit to, use, BEGIN, our and subroutine declaration.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2021-10-21 01:04 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (82 votes). Check out past polls.