I created a simple test module ./mods/My/Module.pm6
:
unit module My::Module;
use v6;
sub hello () is export {
say "Hello";
}
Then, I have a test script ./p.p6
:
#! /usr/bin/env perl6
use v6;
use My::Module;
My::Module::hello();
Then I set PERL6LIB
to include the folder ./mods
, and then run the script:
$ ./p.p6
Could not find symbol '&hello'
in block <unit> at ./p.p6 line 7
However, if I replace the line My::Module::hello()
in the script with hello()
it works fine. What am I missing here?
If you export hello you can simply use it
use v6;
use lib <lib>; # hint: no need to tinker with the environment
use My::Module;
hello();
If you really WANT to use a fully qualified name, you have to use the our keyword.
our sub hello () is export {
say "Hello";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With