[英]How to include file in Raku
I have two Raku files:我有两个 Raku 文件:
hello.p6:你好.p6:
sub hello
{
say 'hello';
}
and main.p6:和 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文件 Hello.pm6
module Hello;
sub hello() is export {
say 'hello';
}
File hello.p6:文件 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:在 Rakudo 中,使用显式文件语法和显式导出列表似乎对我有用:
main.p6:主.p6:
require Hello:file('Hello.p6') <hello>;
hello();
hello.p6:你好.p6:
sub hello {
say 'hello';
}
Source: http://perlcabal.org/syn/S11.html#Runtime_Importation来源:http: //perlcabal.org/syn/S11.html#Runtime_Importation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.