Learning Perl 6Okay, let's see what we can do to get the basics of Perl 6 down. The Shell
Notice that you don't need to use semi-colons in the
shell. Pugs is pretty generous in that regard. Perl 6 uses
So now we know how to print a line of text. Okay, now let's get some user input.
This is a pretty simple example of declaration and
assignment. Perl users should already be familiar with
But what's that on the other side of the equal sign?
It's certainly not how we're used to getting our
user input. This is the new Perl 6 way. Hey, I'll be
honest. I don't really understand what's going on
with the extra dollar sign, but I do get that
I enter my name, and the Pugs shell shows us the return
value that gets assigned to
After all these little changes, I need to see something that works the same.
String interpolation seems to work the same as it always
has, at least for simple scalars like
So interpolate or concatenate, whichever. Now that we've played a little bit in the Pugs shell, handling input and output from the Perl 6 perspective, let's put it all into a script. Writing a Quick ScriptLet's write a script version of what we did, with a little addition.
Since I'm still doing a lot of Perl 5 work, I chose
to save this file as First thing you'll notice is that we're back to using semi-colons; We may not need them inside the shell, but the interpreter still needs them to separate statements while handling a file. I also used the good old Running this script is very easy, assuming that pugs is on your path.
And that's our quick glance at some of the small differences between Perl 5 and Perl 6. I'll look at more when I get the opportunity. |
![]() |
|
|
Copyright 1999 - 2009 Brian Wisti
|
||