šŸ“˜ The need keyword to use a module in Perl 6

To just load a module and do no exports, use the need keyword.

Let us create a module named N, which contains the sub n(). This time, the sub is declared as our but with no is export.

unit module N;Ā 

our sub n() {
Ā Ā Ā  say "N::n()";

Then you need a module and may use its methods using the fully qualified names.

need N;

The sequence of the two instructions: need M; import M; (now import should always come after the need) is equivalent to a single use M; statement.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s