πŸ“˜ 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 *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code