Question

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?

Was it helpful?

Solution 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

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top