multiline comments don't work as explained in the FAQ

Discussion in 'Perl Misc' started by fake, Jun 20, 2004.

  1. fake

    fake Guest

    From the FAQ:
    How can I comment out a large block of perl code?

    Use embedded POD to discard it:

    # program is here

    =for nobody
    This paragraph is commented out

    # program continues

    =begin comment text

    all of this stuff

    here will be ignored
    by everyone

    =end comment text

    =cut

    This can't go just anywhere. You have to put a pod directive where
    the parser is expecting a new statement, not just in the middle of
    an expression or some other arbitrary yacc grammar production.
    >>>>>>>>>>>>>>>



    However, only a "1" is printed from this program:
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..



    #!c:/perl/bin/perl

    print "\n 1";


    =begin comment text

    print "\n 2";



    =end comment text

    print "\n 3";



    >>>>>>>>>>>>>>


    Hence the multiline comments as explained in the perldoc do not work.

    That is all...
     
    fake, Jun 20, 2004
    #1
    1. Advertising

  2. fake

    Jacob Guest

    On Sun, 20 Jun 2004 01:08:28 -0500, a posting issued forth from fake...
    > From the FAQ:
    > How can I comment out a large block of perl code?
    >
    > Use embedded POD to discard it:
    >
    > # program is here
    >
    > =for nobody
    > This paragraph is commented out
    >
    > # program continues
    >
    > =begin comment text
    >
    > all of this stuff
    >
    > here will be ignored
    > by everyone
    >
    > =end comment text
    >
    > =cut
    >
    > This can't go just anywhere. You have to put a pod directive where
    > the parser is expecting a new statement, not just in the middle of
    > an expression or some other arbitrary yacc grammar production.
    >>>>>>>>>>>>>>>>

    >
    >


    Hmmm, what version of perl? Mine (5.8.3 on Fedora Core 2) says

    Found in /usr/lib/perl5/5.8.3/pod/perlfaq7.pod
    How can I comment out a large block of perl code?

    You can use embedded POD to discard it. Enclose the blocks you
    want to comment out in POD markers, for example "=for nobody" and "=cut"
    (which marks ends of POD blocks).

    # program is here

    =for nobody

    all of this stuff

    here will be ignored
    by everyone

    =cut

    # program continues

    The pod directives cannot go just anywhere. You must put a pod
    directive where the parser is expecting a new statement, not just in the
    middle of an expression or some other arbitrary grammar production.

    See perlpod for more details.

    > However, only a "1" is printed from this program:
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

    >
    >
    > #!c:/perl/bin/perl
    >
    > print "\n 1";
    >
    >
    >=begin comment text
    >
    > print "\n 2";
    >
    >
    >
    >=end comment text
    >
    > print "\n 3";
    >
    >


    You forgot '=cut'...

    >
    >>>>>>>>>>>>>>>

    >
    > Hence the multiline comments as explained in the perldoc do not work.
    >
    > That is all...
    >


    #!/usr/bin/perl

    print "1\n";

    =for nobody

    print "2\n";

    =cut

    print "3\n";

    __END__

    prints:

    1
    3

    That seems to work to me...

    --
    Jacob

    To email me, remove '-not-really' and '-possibly' from my email address.
     
    Jacob, Jun 20, 2004
    #2
    1. Advertising

  3. fake

    Matt Garrish Guest

    "fake" <> wrote in message
    news:...
    > From the FAQ:
    > How can I comment out a large block of perl code?
    >
    > Use embedded POD to discard it:
    >
    > # program is here
    >
    > =for nobody
    > This paragraph is commented out
    >
    > # program continues
    >
    > =begin comment text
    >
    > all of this stuff
    >
    > here will be ignored
    > by everyone
    >
    > =end comment text
    >
    > =cut

    ^^^^^^^

    Important little bit, there.


    > This can't go just anywhere. You have to put a pod directive where
    > the parser is expecting a new statement, not just in the middle of
    > an expression or some other arbitrary yacc grammar production.
    > >>>>>>>>>>>>>>>

    >
    >
    > However, only a "1" is printed from this program:
    > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

    >
    >
    > #!c:/perl/bin/perl
    >
    > print "\n 1";
    >
    >
    > =begin comment text
    >
    > print "\n 2";
    >
    >
    >
    > =end comment text
    >


    Hmm, no =cut here...


    > print "\n 3";
    >
    >
    >
    > >>>>>>>>>>>>>>

    >
    > Hence the multiline comments as explained in the perldoc do not work.
    >
    > That is all...


    Failing to understand the documentation is not grounds for claiming it is
    wrong. Next time ask for an explanation of why your code is not working
    before you assume that you are right and the documentation is wrong...

    Matt
     
    Matt Garrish, Jun 20, 2004
    #3
  4. fake

    fake Guest

    On Sun, 20 Jun 2004 11:41:30 -0400, "Matt Garrish"
    <> wrote:

    >
    >"fake" <> wrote in message
    >news:...
    >> From the FAQ:
    >> How can I comment out a large block of perl code?
    >>
    >> Use embedded POD to discard it:
    >>
    >> # program is here
    >>
    >> =for nobody
    >> This paragraph is commented out
    >>
    >> # program continues
    >>
    >> =begin comment text
    >>
    >> all of this stuff
    >>
    >> here will be ignored
    >> by everyone
    >>
    >> =end comment text
    >>
    >> =cut

    > ^^^^^^^
    >
    >Important little bit, there.
    >
    >
    >> This can't go just anywhere. You have to put a pod directive where
    >> the parser is expecting a new statement, not just in the middle of
    >> an expression or some other arbitrary yacc grammar production.
    >> >>>>>>>>>>>>>>>

    >>
    >>
    >> However, only a "1" is printed from this program:
    >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..

    >>
    >>
    >> #!c:/perl/bin/perl
    >>
    >> print "\n 1";
    >>
    >>
    >> =begin comment text
    >>
    >> print "\n 2";
    >>
    >>
    >>
    >> =end comment text
    >>

    >
    >Hmm, no =cut here...
    >
    >
    >> print "\n 3";
    >>
    >>
    >>
    >> >>>>>>>>>>>>>>

    >>
    >> Hence the multiline comments as explained in the perldoc do not work.
    >>
    >> That is all...

    >
    >Failing to understand the documentation is not grounds for claiming it is
    >wrong. Next time ask for an explanation of why your code is not working
    >before you assume that you are right and the documentation is wrong...
    >



    I cannot understand why I did not see the "=cut". I must have read the
    perdoc query results 6 times. Also, I read at least 10
    webpages/newsgroup posts on the subject, and the first time I saw
    "=cut" was in this thread. Very peculiar! But it works....thanks!
     
    fake, Jun 20, 2004
    #4
  5. fake

    Matt Garrish Guest

    "fake" <> wrote in message
    news:...

    >
    > I cannot understand why I did not see the "=cut". I must have read the
    > perdoc query results 6 times. Also, I read at least 10
    > webpages/newsgroup posts on the subject, and the first time I saw
    > "=cut" was in this thread. Very peculiar! But it works....thanks!
    >


    Never trust a web page! Especially when there's a whole perldoc on the
    subject:

    http://www.perldoc.com/perl5.8.4/pod/perlpod.html

    (irony of referencing a web page duly noted... : )

    Matt
     
    Matt Garrish, Jun 20, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Uwe Ziegenhagen
    Replies:
    5
    Views:
    7,688
    oceamus
    Jan 27, 2010
  2. Stephane CHAZELAS

    Re: Stripping multiline C comments without using Lex

    Stephane CHAZELAS, Feb 4, 2004, in forum: C Programming
    Replies:
    3
    Views:
    939
    Jens Schweikhardt
    Feb 5, 2004
  3. Philippe C. Martin

    Re: Case Sensitive, Multiline Comments

    Philippe C. Martin, May 26, 2005, in forum: Python
    Replies:
    0
    Views:
    399
    Philippe C. Martin
    May 26, 2005
  4. Elliot Temple

    Case Sensitive, Multiline Comments

    Elliot Temple, May 26, 2005, in forum: Python
    Replies:
    32
    Views:
    1,371
    Magnus Lyck?
    Jun 2, 2005
  5. dale zhang
    Replies:
    8
    Views:
    435
    Tintin
    Nov 30, 2004
Loading...

Share This Page