Probably a stupid question but....

Discussion in 'Perl Misc' started by Bill H, Oct 1, 2008.

  1. Bill H

    Bill H Guest

    In all the years I have been working in perl (and I do not call myself
    an expert by any means), I have never come across a way of having
    multi-line comments. In PHP, C, Actionscript you have the /* && */ to
    mark a block, is there one in perl? Only reason I have decided to ask
    now, I just commented out 50 plus lines of code using # enter arrow
    left repeat and I know (or hope) there has to be a much simpler way
    of doing it.

    Bill H
     
    Bill H, Oct 1, 2008
    #1
    1. Advertisements

  2. http://perldoc.perl.org/perlpod.html
     
    Andrzej Adam Filip, Oct 1, 2008
    #2
    1. Advertisements

  3. Bill H

    Tim Greer Guest

    I usually just have a block of text or code I don't want to run, and I
    do a:

    =junkstuff
    block
    of
    text
    etc
    here
    =cut


    If the code you want to not run is after all the code you want to use,
    you can use __END__ or something else, depending on the formatting, if
    you need code below it, etc.
     
    Tim Greer, Oct 1, 2008
    #3
  4. Bill H

    Ben Morrow Guest

    perldoc -q comment
    Get a decent editor? V <select code> :s/^/# works fine for me... :)

    Ben
     
    Ben Morrow, Oct 1, 2008
    #4
  5. Bill H

    Dr.Ruud Guest

    Bill H schreef:
    There are many ways. You can put an if(0) block around code.

    $ perl -MO=Deparse -e'
    my $x = 1;
    my $y = 2;
    my $z = 3;
    '
    my $x = 1;
    my $y = 2;
    my $z = 3;
    -e syntax OK



    $ perl -MO=Deparse -e'
    my $x = 1;
    if (0) {
    my $y = 2;
    }
    my $z = 3;
    '
    my $x = 1;
    '???';
    my $z = 3;
    -e syntax OK



    Or use a heredoc, if it is about textual comment.

    $ perl -MO=Deparse -Mstrict -Mwarnings -e'

    0 if !<<" */";
    /*
    * blabla
    *
    */

    exit;
    '
    use warnings;
    use strict 'refs';
    '???';
    exit;
    -e syntax OK


    Or use pod.
     
    Dr.Ruud, Oct 3, 2008
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.