sid_com sid_com - 6 months ago 35
Perl Question

Does Perl6 support something equivalent to Perl5's __DATA__ and __END__ sections?

Does perl6/Rakudo have something equivalent to perl5's



Quote S26:

Named Perldoc 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. Synopsis 2 describes the new Perl 6 interface for inline data.

In theory you should be able to do something like this (somebody please fix the syntax if it’s off):

use v6;

=begin DATA
=end DATA

say @=DATA;

In practice it seems that Rakudo does not support that, yet.