Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am eager to learn Raku(Perl 6) and its syntax.

I already have Perl 5 installed in my Ubuntu machine.

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.

I want to install Raku in the same Ubuntu system. I have couple of questions:

  1. How can I install Raku ?
  2. If I install Raku, will Perl 5.26 will be get wipedout/updated? I want Perl 5.26 in my system because couple of scripts are running in Perl 5.
  3. Can I have 2 versions of Perl in single server ?
  4. Once if I install Raku, how can I run the Raku/Perl 5 code in Ubuntu server? Is it like I should mention use Perl 5.26; at the beginning? By default which version of Perl it will take?
  5. How can I run Raku code?
like image 464
vkk05 Avatar asked Oct 22 '19 07:10

vkk05


1 Answers

$ 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)

The Raku compiler is in a package called rakudo. That package includes a program called perl6 which is the actual Raku compiler. The Perl compiler and the Raku compiler are two completely separate programs, so there is no problem having them both installed and running code using either of them. They are as separate as Perl and PHP.

Update: In a (now, bizarrely, deleted) comment, you asked

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

You do it in exactly the same way as you would do it for any programming language where the code is compiled or interpreted on each execution - Perl, Python, Ruby, bash, they all work the same way.

You can write a text file containing Raku code and run it with perl6 your_file_name.

Or you can put the correct shebang line (which is #!/usr/bin/perl6) at the top of the file and make the file executable with chmod +x your_file_name.

like image 130
Dave Cross Avatar answered Oct 30 '22 08:10

Dave Cross