📘 Exporting a sub from a module in Perl 6

📘 Exporting a sub from a module in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.

The my and our variables, as well as subs, which are defined in the module, are not visible outside of its scope by default. To export a name, the is export trait is required.

unit module X; 

sub x() is export {
    say "X::x()";

This is all you need to do to be able to call the x() sub in the programme using your module.

Leave a Reply

Your email address will not be published. Required fields are marked *