当我尝试使用 Rakudo 运行我的脚本时,为什么会出现“除以零"错误? [英] Why do I get 'divide by zero` errors when I try to run my script with Rakudo?

查看:73
本文介绍了当我尝试使用 Rakudo 运行我的脚本时,为什么会出现“除以零"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚构建了 Rakudo 和 Parrot,这样我就可以玩它并开始学习 Perl 6.我下载了 Perl 6 书并愉快地输入了第一个演示程序(网球锦标赛示例).

当我尝试运行程序时,出现错误:

除以零当前指令:'' pc -1((未知文件):-1)

我在构建目录中有我的 perl6 二进制文件.我在rakudo build目录下加了一个scripts目录:

 rakudo|- perl6\- 脚本|- perlbook_02.01\- 分数

如果我试图从我的脚本目录中运行一个简单的 hello world 脚本,我也会得到同样的错误:

#!/home/daotoad/rakudo/perl6使用 v6;说护士你好!";

但是,如果我从 rakudo 目录运行它,它就可以工作.

听起来我需要设置一些环境变量,但我不知道这些变量是什么以及赋予它们什么值.

有什么想法吗?

更新:

此时我宁愿不安装 rakudo,我宁愿只从构建目录运行东西.这将允许我在尝试不同的 Perl6 构建时尽量减少对系统的更改(Rakudo * 即将推出).

README 文件鼓励我认为这是可能的:

<块引用>

 $ cd rakudo$ perl Configure.pl --gen-parrot$ make

这将在文件中创建一个perl6"或perl6.exe"可执行文件当前(rakudo)目录.然后可以运行程序使用如下命令创建构建目录:

 $ ./perl6 hello.pl

重读后,我发现在构建目录外运行脚本之前必须安装rakudo这一事实的参考:

<块引用>

一旦构建,Rakudo 的 make install 目标将安装 Rakudo和它的库到 Parrot 安装中创造它.在执行此步骤之前,perl6"可执行文件上面的 make 创建的只能从根目录可靠地运行Rakudo 的构建目录.make install 执行后,安装的可执行文件可以从任何目录运行(只要用于创建它的 Parrot 安装保持不变).

所以看起来我需要安装 rakudo 才能使用 Perl 6.

下一个问题是,rakudo 安装在哪里?README 说到用于构建的 Parrot 安装.

我在构建中使用了 --gen-parrot 选项,看起来它安装到 rakudo/parrot-install 中.那么 rakudo 会安装到我的 rakudo\parrot-install 中吗?

阅读Makefile,支持这个结论.我运行了 make install,它确实安装到了 parrot_install 中.

对于 Perl6 的新手来说,构建/安装过程的这一部分不清楚.我会看看我是否可以提供一个文档补丁来澄清事情.

我的头顶:

  1. 强调在构建之外运行脚本之前运行 make install.此要求目前隐藏在段落中间,很容易被浏览文档的人(我)忽略.

  2. 明确声明使用 --gen-parrot 会将 perl6 安装到 parrot_install 目录中.

解决方案

您是否在 Rakudo 中运行了 make install?

为了能够在其构建目录之外使用 Rakudo,有必要这样做(这就是为什么 README 和 http://rakudo.org/how-to-get-rakudo 告诉你去做.

别担心,默认安装位置是本地的(在 rakudo 目录下的 parrot_install/bin/perl 中).

I just built Rakudo and Parrot so that I could play with it and get started on learning Perl 6. I downloaded the Perl 6 book and happily typed in the first demo program (the tennis tournament example).

When I try to run the program, I get an error:

Divide by zero
current instr.: '' pc -1 ((unknown file):-1)

I have my perl6 binary in the build directory. I added a scripts directory under the rakudo build directory:

  rakudo
  |- perl6
  \- scripts
     |- perlbook_02.01
     \- scores

If I try to run even a simple hello world script from my scripts directory I get the same error:

#!/home/daotoad/rakudo/perl6

use v6;
say "Hello nurse!";

However if I run it from the rakudo directory it works.

It sounds like there are some environment variables I need to set, but I am at a lost as to what the are and what values to give them.

Any thoughts?

Update:

I'd rather not install rakudo at this point, I'd rather just run things from the build directory. This will allow me to keep my changes to my system minimal as I try out different Perl6 builds (Rakudo * is out very soon).

The README file encouraged me to think that this was possible:

   $ 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

Upon rereading, I found a reference to the fact that it is necessary to install rakudo before running scripts outside the build directory:

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 by make above can only be reliably run from the root of Rakudo's build directory. After make 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).

So it looks like I need to install rakudo to play with Perl 6.

The next question is, where rakudo be installed? README says into the Parrot install used to build.

I used the --gen-parrot option in my build, which looks like it installs into rakudo/parrot-install. So rakudo will be installed into my rakudo\parrot-install?

Reading the Makefile, supports this conclusion. I ran make install, and it did install into parrot_install.

This part of the build/install process is unclear for a newbie to Perl6. I'll see if I can up with a documentation patch to clarify things.

Off the top of my head:

  1. Emphasize running make install before running scripts outside of build. This requirement is currently burried in the middle of a paragraph and can be easily missed by someone skimming the docs (me).

  2. Explicitly state that with --gen-parrot will install perl6 into the parrot_install directory.

解决方案

Did you run make install in Rakudo?

It's necessary to do it to be able to use Rakudo outside its build directory (and that's why both the README and http://rakudo.org/how-to-get-rakudo tell you to do it.

Don't worry, the default install location is local (in parrot_install/bin/perl inside your rakudo directory).

这篇关于当我尝试使用 Rakudo 运行我的脚本时,为什么会出现“除以零"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆