To use a module, use a use. This keyword searches for the module, loads it and imports what can be imported. Thus, the subs or variables with the is export trait will be accessible in the code after module is imported.

First, create a module saved in the file

module Greet;

sub hey($name) is export {
    say "Hey, $name!";

Second, use it in the Perl 6 code:

use Greet;

hey("you"); # Hey, you!

The Perl 6 compiler will search for the module in the directories it knows to be Perl 6 libraries. It the module is located in another place, use the -I command line option, for example: perl6 -I.

Another example of the module, this time with nested name and with the code of the module in a block:

module Greet::Polite {
    sub hello($name) is export {
        say "Hello, $name!";

The module file should be saved as Greet/ Its usage is as straightforward as before:

use Greet;
use Greet::Polite;

hey("you"); # Of Greet
hello("Mr. X"); # Of Greet::Polite

The actions behind the `use` happen at compile time.