Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > multiline comments don't work as explained in the FAQ

Reply
Thread Tools

multiline comments don't work as explained in the FAQ

 
 
fake
Guest
Posts: n/a
 
      06-20-2004
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...

 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      06-20-2004
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.
 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      06-20-2004

"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


 
Reply With Quote
 
fake
Guest
Posts: n/a
 
      06-20-2004
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!

 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      06-20-2004

"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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flex source for parsing files with multiline comments Uwe Ziegenhagen C++ 5 01-27-2010 01:09 AM
rpasken@eas.slu.edu , You have made comments that Momentum is not Conserved in my PAPER. It is not CORRECT. It is explained in 100 Years of E=mc2 AJAY SHARMA C++ 0 10-04-2006 02:02 PM
Re: Case Sensitive, Multiline Comments Philippe C. Martin Python 0 05-26-2005 08:09 PM
how to define a variable to hold a multiline text input in perl from html multiline textbox dale zhang Perl Misc 8 11-30-2004 06:53 AM
Re: Stripping multiline C comments without using Lex Stephane CHAZELAS C Programming 3 02-05-2004 01:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57