|Subject:||Perl6 features out of date|
|Date:||Wed, 16 Jan 2013 13:55:31 +0000|
|To:||rakudobug [...] perl.org|
|From:||kevin dawson <kevin [...] dawson10.plus.com>|
Message body is not shown because sender requested not to inline it.
ticket as requested by FROGGS
the info in ->
relating to Lexing and Parsing - Pod implies all works,
But This is not the case
Data Blocks from -
Named Pod blocks whose typename is data are the Perl 6 equivalent of the Perl 5 __DATA__ section. The difference is that =data blocks are just regular Pod blocks and may appear anywhere within a source file, and as many times as required.
There is a corresponding variable, $=data, from which each =data block can be retrieved. $=data holds an object that does both the Associative and Positional roles.
Each =data block can be given a :key option, to name it. The contents of any =data block with a key are accessible (as a single string) via the Associative aspect of $=data object. For example:
=begin data :key<Virtues> Laziness Impatience Hubris =end data say 'The three virtues are:'; say $=data<Virtues>;
The contents of any =data block that does not have a :key are accessible (as a single string) via the Positional aspect of $=data. Unkeyed =data blocks are stored in the same order they appear in the file. For example:
say 'The second anti_Virtue is: ', $=data; =data Industry =data Patience =data Humility
Note that, as the preceding example illustrates, because Pod is a compile-time phenomenon, it is possible to specify =data blocks after the point in the source where their contents will be used (provided they're not being used in a BEGIN, of course).
When $=data itself is stringified, it returns the concatenation of all the unkeyed =data blocks the parser has seen.
=data blocks are never rendered by the standard Pod
We Now Generate the following Output:
$ perl6 data_blocks.p6
Variable $=data is not declared
------> say $=data<Virtues>⏏;
expecting any of: