Search code examples
perlrakurakudo

Does Perl6 (a.k.a Raku) support something equivalent to Perl5's __DATA__ and __END__ sections?


Does perl6/Rakudo have something equivalent to perl5's __DATA__ or __END__ sections?


Solution

  • 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.