我刚刚构建了 Rakudo 和 Parrot,这样我就可以使用它并开始学习 Perl 6。我下载了 Perl 6 书并愉快地输入了第一个演示程序(网球锦标赛示例)。
当我尝试运行该程序时,出现错误:
Divide by zero
current instr.: '' pc -1 ((unknown file):-1)
我有我的
perl6
生成目录中的二进制文件。我在 rakudo 构建目录下添加了一个脚本目录: rakudo
|- perl6
\- scripts
|- perlbook_02.01
\- scores
如果我尝试从我的脚本目录运行一个简单的 hello world 脚本,我会得到同样的错误:
#!/home/daotoad/rakudo/perl6
use v6;
say "Hello nurse!";
但是,如果我从
rakudo
运行它它工作的目录。听起来我需要设置一些环境变量,但我不知道它们是什么以及赋予它们什么值。
有什么想法吗?
更新:
此时我宁愿不安装 rakudo,我宁愿只从构建目录运行东西。这将允许我在尝试不同的 Perl6 构建(Rakudo * 很快推出)时对我的系统所做的更改保持最小。
README 文件鼓励我认为这是可能的:
$ cd rakudo $ perl Configure.pl --gen-parrot $ make
This will create a "perl6" or "perl6.exe" executable in the current (rakudo) directory. Programs can then be run from the build directory using a command like:
$ ./perl6 hello.pl
重读后,我发现在运行构建目录外的脚本之前必须安装 rakudo 的事实的引用:
Once built, Rakudo's
make install
target will install Rakudo and its libraries into the Parrot installation that was used to create it. Until this step is performed, the "perl6" executable created bymake
above can only be reliably run from the root of Rakudo's build directory. Aftermake install
is performed, the installed executable can be run from any directory (as long as the Parrot installation that was used to create it remains intact).
所以看起来我需要安装 rakudo 才能使用 Perl 6。
下一个问题是,rakudo 安装在哪里? README 说到用于构建的 Parrot 安装。
我用了
--gen-parrot
我的构建中的选项,看起来它安装到 rakudo/parrot-install
.所以 rakudo 将安装到我的 rakudo\parrot-install
中?阅读Makefile,支持这个结论。我跑了
make install
,它确实安装到 parrot_install
.对于 Perl6 的新手来说,构建/安装过程的这一部分不清楚。我会看看我是否可以提供一个文档补丁来澄清事情。
在我的头顶:
make install
在构建之外运行脚本之前。这个要求目前被埋在一个段落的中间,很容易被浏览文档的人(我)忽略。 --gen-parrot
明确说明将 perl6 安装到 parrot_install
目录。 最佳答案
你跑了吗make install
在乐堂?
必须这样做才能在其构建目录之外使用 Rakudo(这就是 README 和 http://rakudo.org/how-to-get-rakudo 都告诉您这样做的原因。
别担心,默认安装位置是本地的(在 rakudo 目录中的 parrot_install/bin/perl 中)。
关于raku - 当我尝试使用 Rakudo 运行我的脚本时,为什么会出现 'divide by zero` 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3144043/