質問

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?

役に立ちましたか?

解決 2

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

他のヒント

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;
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top