在 Ubuntu 中安装 Raku (Perl 6) 以及 Perl 5.26

Install Raku (Perl 6) in Ubuntu along with Perl 5.26

我渴望学习 Raku(Perl 6) 及其语法。

我的 Ubuntu 机器上已经安装了 Perl 5。

vinod@ubuntu-s-1vcpu-1gb-nyc1-01:~$ perl -v

This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 67 registered patches, see perl -V for more detail)

Copyright 1987-2017, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

我想在同一个 Ubuntu 系统中安装 Raku。我有几个问题:

  1. 如何安装 Raku?
  2. 如果我安装 Raku,Perl 5.26 会得到 wipedout/updated 吗?我想在我的系统中使用 Perl 5.26,因为几个脚本在 Perl 5 中 运行ning。
  3. 我可以在单个服务器上安装 2 个版本的 Perl 吗?
  4. 一旦我安装了 Raku,我如何在 Ubuntu 服务器中 运行 Raku/Perl 5 代码?我应该在开头提到 use Perl 5.26; 吗?默认使用哪个版本的 Perl?
  5. 如何运行乐库代码?
$ sudo apt-get install rakudo 
[ ... stuff happens ... ]
$ perl6 -v
This is Rakudo version 2018.03 built on MoarVM version 2018.03
implementing Perl 6.c.
$ perl -v

This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 67 registered patches, see perl -V for more detail)

Raku 编译器位于名为 rakudo 的包中。该软件包包括一个名为 perl6 的程序,它是实际的 Raku 编译器。 Perl 编译器和 Raku 编译器是两个完全独立的程序,因此安装它们和使用它们中的任何一个 运行ning 代码都没有问题。它们与 Perl 和 PHP.

一样独立

更新: 在一条(现在,很奇怪,已删除的)评论中,您问

What was the way to open a vi editor and write a code in that

您执行此操作的方式与在每次执行时编译或解释代码的任何编程语言完全相同 - Perl、Python、Ruby、bash, 它们的工作方式相同。

您可以编写一个包含 Raku 代码的文本文件,并 运行 它 perl6 your_file_name

或者您可以将正确的 shebang 行(即 #!/usr/bin/perl6)放在文件的顶部,并使用 chmod +x your_file_name.

使文件可执行

这里有一个社区维护的 Rakudo 最新版本的存储库:https://nxadm.github.io/rakudo-pkg/

这通常在每次正式发布后几天更新,目前是 2019.07.1