I have two Raku files:
hello.p6:
sub hello
{
say 'hello';
}
and main.p6:
require 'hello.p6';
hello();
But don't work. How to can include the first file in the main script?
Just for the record, the proper solution is to use a module:
File Hello.pm6
module Hello;
sub hello() is export {
say 'hello';
}
File hello.p6:
use v6;
use lib '.'; # to search for Hello.pm6 in the current dir
use Hello;
hello;
Using explicit file syntax and explicit export list seems to work for me in Rakudo:
main.p6:
require Hello:file('Hello.p6') <hello>;
hello();
hello.p6:
sub hello {
say 'hello';
}
Source: http://perlcabal.org/syn/S11.html#Runtime_Importation
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