# New Ticket Created by  kevin dawson 
# Please include the string:  [perl #116419]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116419 >


use v6;

=begin data :key<Virtues>
Laziness
Impatience
Hubris
=end data

say 'The three virtues are:';
say $=data<Virtues>;

say 'The second anti_Virtue is: ', $=data[1];

=data Industry
=data Patience
=data Humility

Hi All,

ticket as requested by FROGGS

the info in -> http://perl6.org/compilers/features

relating to Lexing and Parsing - Pod implies all works,


But This is not the case

Data Blocks from - http://perlcabal.org/syn/S26.htm


      Data blocks <http://perlcabal.org/syn/S26.html#___top>

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[1];

     =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 renderers.


We Now Generate the following Output:

$ perl6 data_blocks.p6
===SORRY!===
Variable $=data is not declared
at data_blocks.p6:10
------> say $=data<Virtues>?;
     expecting any of:
         postfix

regards
bowtie


Reply via email to