Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Multi-line comment not supported with in an array

by k_manimuthu (Monk)
on Aug 13, 2010 at 05:56 UTC ( #854837=perlquestion: print w/ replies, xml ) Need Help??
k_manimuthu has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I used multi-line comment for few places. The codes are working fine out of the array declearation. But the multi-line comment are not supported inside of the array.( Single line comment supported Here.)

Could someone please explain, why the comments not supported the place and how can i do this.

Below i placed the sample code and their error.

Thanks
Mani Muthu

Sample Code

use Data::Dumper; ($base, $next)=1; =mulitline comment supported my comment lines out of the array =cut @option=( [ 1,2, sub{ # few lines for # function process $base }], =for [ undef, undef, sub{ $next } ], =cut [3,4], ); print Dumper @option;

Error

syntax error at data.pl line 17, near "=" Execution of data.pl aborted due to compilation errors.

Comment on Multi-line comment not supported with in an array
Select or Download Code
Re: Multi-line comment not supported with in an array
by moritz (Cardinal) on Aug 13, 2010 at 06:16 UTC
    From perlsyn:
    Perl has a mechanism for intermixing documentation with source code. While itís expecting the beginning of a new statement, if the compiler encounters a line that begins with an equal sign and a word, like this
    =head1 Here There Be Pods!
    Then that text and all remaining text up through and including a line beginning with "=cut" will be ignored. The format of the intervening text is described in perlpod.

    (Emphasis by me).

    POD is only allowed at statement boundaries. This is probably because it's very confusing to have a huge piece of text between the beginning and the end of a statement, and thus would make reading the code much harder.

    Perl 6 - links to (nearly) everything that is Perl 6.
Re: Multi-line comment not supported with in an array
by JavaFan (Canon) on Aug 13, 2010 at 08:36 UTC
    POD != comments.

    Perl does support comments, and comments can be introduced almost anywhere where a new token is expected.

    However, the problem you have is with POD. The interpreter itself will only skip POD sections if it's expecting a new statement. Which is were your problem lies. On the flip side, I'm not aware of any POD parser that isn't naïve, and extracts POD from files where perl wouldn't. POD parsers typically just look for /^=\w/, ignoring context. (Really bad parsers look for /^=/).

Re: Multi-line comment not supported with in an array
by jethro (Monsignor) on Aug 13, 2010 at 08:44 UTC

    I assume you want to uncomment code without tediously adding '#' to each line. POD wasn't made for this. You should check your editor, many have macro abilities and macros can be used to add or remove '#' from a region of text automatically.

    Emacs and vi (and all descendants of vi) can do this, just to name a few examples

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://854837]
Approved by prasadbabu
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-09-17 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls