Re: Multiline comment in Perl

[email protected] ("Octavian Rasnita")
Newsgroups perl.beginners
Message-ID <02a601c8b9c3$7d163db0$c2a2b451@teddy>
From: "Rob Dixon" <[email protected]>
> The documentation that John referred you to recommends
>
>  =begin comment
>    :
>  =end
>
> Which may be a trifle awkward, but I'm sure there are worse things that 
> happen
> to you in your day. It takes less than a second to type, and if you do it 
> a lot
> you could set up a macro in your editor.

Unfortunately it doesn't work that way.
Even the POD documentation says that in the same perldoc -q ...:

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

Here is an example that doesn't work:

if (1) {

=begin comment

print "ok";

=end comment

}

It gives the following error:
Missing right curly or square bracket at E:\zzz.pl line 11, at end of line

If the user uses the not recommended

=start
...
...
=cut

then it simply works, at least until a newer version of perl will decide 
that this should give an error.

Octavian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.