This tutorial is the first in a series on learning the basics of the Perl 6 programming language. Check back about a once a month for a new installment.
It’s been 23 years since I first learned Perl. And at least 15 of those years were spent wondering what the new Perl 6 language was going to do when it was finally released. That magical, long-awaited day arrived in 2015 — and, well, I never got around to actually installing Perl 6 and playing around with it…
It was a new adventure, which, yes, led to the discovery of some fun and powerful new features. But you also catch glimpses of the dedicated community behind it, just by casually wandering through Perl 6’s installation process.
And in true Perl fashion, I also discovered that even if you’re just installing the language — there’s more than one way to do it.
Install and Run
There’s a series of helpful pages which lead you to a Perl 6 installer. The “Getting Started” page at Perl6.org thoughtfully offers a link to a “downloads” page for Rakudo Star, which it describes as “a Perl 6 distribution with a number of useful modules included.” That page also provides instructions for downloading a tarball on Unix-like systems, but instead I followed its link for downloadable Windows and macOS binaries at Rakudo.org/files. (This page describes Rakudo as “a useful and usable production distribution of Perl 6.”)
So here’s my first observation: Every once in a while there’s a few glitches. When I first visited the page on May 7th, it gave me a superfluous warning that “currently” the site was being served from a back-up server that didn’t have the download files — and suggesting that I instead try a prebuilt third-party package.
But right below that warning was their own icon for a Windows 64-bit binary file — which downloaded just fine!
And in general, the community support seems top notch. If you’re trying to download the Unix tarball, the last link on the page says “Need help? Talk to us,” which links to a Kiwi “webchat” page that will lead you directly to the #perl6 chat channel on freenode IRC.
Though I had to laugh when I clicked on the last link on the Getting Started page — “Get involved!” It was apparently intended to recruit volunteers to write documentation or tests and help find and report bugs. But when I clicked on it on July 1st, all it said was “not found.”
But installation turns out to be an incredibly simple two-step process that can be summarized as “download then run.” (There’s a page of installation instructions where the first step is simply to download the installer file from the link, while the second step is “Run the installer and follow the instructions on the screen.”) Even there, the documentation is simple yet thorough. That page also offers separate specific instructions if you’re trying to install the third-party Chocolatey package, and advice for installations on 32-bit Windows systems or on the Windows Subsystem for Linux.
But for me it was easy. I just clicked on the page’s link for “the latest Rakudo Star 64-bit Windows .msi installer file,” which downloaded a 25.8MB file.
If you’re following along with my progress, here’s my standard piece of free advice: As with most installation processes, your biggest obstacle is your own system.
I had the same issue, Mike. I signed up for an online class — and then couldn't get past the part where I set up my development environment.
Harvard's CS50 got around that by giving everyone a hypervisor with a pre-configured work environment (including all the right software) https://t.co/N98oasv6zW
— David Cassel (@DavidCasselTNS) June 1, 2019
After the obligatory warning from my browser about how I was clicking on an executable file, I then received a second separate warning courtesy of Windows Defender. (Clicking its “More Info” button added a “Run anyway” button to the window, and clicking that finally got me to the Rakudo Star 2019.03 setup wizard.)
All the necessary Perl 6 files are installed in subdirectories of C:\rakudo (as the installation page explains), with the executables in C:\rakudo\bin\. Currently, there’s no way to change the location, but the setup wizard includes a checkbox for automatically setting a path environment variable so Perl 6 can be run from any directory.
And so naturally this triggered another warning, this one from Window 10’s “User Account Control” (an operating system-level security feature) asking me to confirm that I wanted to allow this program to make changes to my system.
I clicked yes, and was told that the installation was completed.
Brave New World
Where is it? There’s no perl6 icon on my desktop.
Of course the next place to check was obviously in a command window (which in 2019 is now magically summoned by typing “cmd” into the run window that appears when you type Windows_key + R). Interestingly, “perl” isn’t a recognized command — this is a Windows command window, after all — but “perl6” now is.
Typing that launches that exotic phenomenon known as the Read-Eval-Print Loop (or REPL). Yes, I’m actually in a Perl 6 environment. After years of writing my Perl 5 code in a separate perl module, and then saving and exiting that file, and then typing its name as an argument after the “perl” command (which summons the perl interpreter) — now I’m in an entirely different workflow.
“The REPL is mostly used for trying a specific piece of code, typically a single line,” it explains. It’s still possible to run your Perl 6 code the “old” way, of course, from standalone files. The Perl 6 intro page recommends giving them a .p6 extension — and points out that you’ll only see text from “print” or “say” statements, and not the results of evaluating each individual line.
I decided to try it the old-fashioned way first. And it’s at that point that I learn that Windows 10 no longer has that command-line text editor I remember launching in days of yore just by typing “Edit.” One web page recommended launching Notepad from the command line — and if you type your desired filename after “notepad,” it will actually prompt you to confirm that you want to create that file… and then create it in the appropriate (current) directory.
So what’s the first thing you do in a new language? Say “hello world,” of course. And I’ve always loved Perl 5’s “say” command (which prints your string and a newline character, so your printed variables don’t all end up bunched on the same line). The only downside is in Perl 5, I always have to remember to add the line of code which enables that feature:
use feature qw(say);
So here’s delightful surprise #1. In Perl 6 — or at least this particular distro — the say command is apparently already included, so I can replace my print statements with say without getting an error.
I type the following into a Notepad text file which I save as perltest.p6.
say "hello world";
say "3 + .14";
And away we go….
> perl6 perltest.p6
3 + .14
Pi is actually included in Perl 6 as a pre-defined value…
This first experiment barely scratches the surface — but at least it confirms that Perl 6 is successfully installed and running, and able to print “hello world” in all of its geeky glory.
At this point, I was greedy for all those new Perl 6 features I’d been hearing about for four years, and there followed a crazed jag of geek-o-riffic experimentation that left me wondering how it suddenly got so late in the evening. That’s a story for another tutorial — but hopefully, this has demonstrated just how easy it is to install Perl 6, and how many resources there are available for those who are curious about the language or are just getting started.
The first step toward understanding a new language is always to play around with it yourself, and I’ll tell you this: playing around with Perl 6 is a lot of fun!