multiline comments don't work as explained in the FAQ

F

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.

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...
 
J

Jacob

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...
 
M

Matt Garrish

fake said:
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
 
F

fake

^^^^^^^

Important little bit, there.



Hmm, no =cut here...



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!
 
M

Matt Garrish

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top