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

标签 perl installation raku rakudo-star

我渴望学习 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 会被删除/更新吗?我希望在我的系统中使用 Perl 5.26,因为有几个脚本在 Perl 5 中运行。
  3. 我可以在单个服务器上拥有 2 个版本的 Perl 吗?
  4. 一旦安装了 Raku,如何在 Ubuntu 服务器上运行 Raku/Perl 5 代码?我是不是应该在开头提到 use Perl 5.26; ?默认情况下它将使用哪个版本的 Perl?
  5. 如何运行 Raku 代码?

最佳答案

$ 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 编译器是两个完全独立的程序,因此安装它们并使用它们中的任何一个运行代码都没有问题。它们就像 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< 使文件可执行.

关于perl - 在 Ubuntu 中安装 Raku (Perl 6) 以及 Perl 5.26,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58498697/

相关文章:

perl - 部署脚本需要更新配置文件中的整数

linux - 在 Perl-Tk 中使用 Button 小部件执行命令

python - 在 Windows 上安装 SciPy 时遇到问题

Linux/UNIX 安装数据文件

signature - 子集 block (或一般的可调用对象)

mysql - IPv6 SQL 到 Perl

perl - 有没有理由在 Perl 包中包含 shebang 行?

Android 在安装过程中检查依赖应用程序?

hash - 在 Raku 中将数字重新排列为非英文字母顺序

sockets - perl6 IO::Socket::INET 无法从套接字接收数据:连接被对等方重置