afoken has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
I have a module with a rather large hash containing default values, and I want to document the key-value pairs right where I define them.
Perfectly working test case, missing POD:
#!/usr/bin/perl -w use strict; my %data=( a => 1, b => 2, ); print join(' ',%data);
The same test case, with POD near the key-value pairs:
#!/usr/bin/perl -w use strict; my %data=( =head1 The "a" key one =cut a => 1, =head1 The "b" key two =cut b => 2, ); print join(' ',%data);
This does not even compile, perl is completely confused about the POD and seems to read it as code:
Bareword found where operator expected at pod-in-structure.pl line 7, +near ""a" key" (Missing operator before key?) Bareword found where operator expected at pod-in-structure.pl line 15, + near ""b key" (Missing operator before key?) syntax error at pod-in-structure.pl line 7, near "( =" Execution of pod-in-structure.pl aborted due to compilation errors.
This happens with perl 5.8.8 on Linux and Strawberry 5.10.0. All blank lines are completely empty, there are no spaces or tabs in those lines. All POD starts in the first column.
As far as I understood the documentation, I should be able to inline POD everywhere outside here-documents. But my two perl binaries seem to have a different oppinion.
So, is there a way to embed POD into a hash definition, is perl broken, or did I miss a piece of documentation?
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I'm confused because perl is confused with POD
by moritz (Cardinal) on Jun 30, 2009 at 21:10 UTC | |
by afoken (Chancellor) on Jun 30, 2009 at 21:22 UTC | |
|
Re: I'm confused because perl is confused with POD
by Utilitarian (Vicar) on Jul 01, 2009 at 06:47 UTC | |
by afoken (Chancellor) on Jul 01, 2009 at 14:11 UTC |