sid_com sid_com - 22 days ago 6
Perl Question

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

Does perl6/Rakudo have something equivalent to perl5's

__DATA__
or
__END__
sections?

Answer

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
Foo
=end DATA

say @=DATA;

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

Comments