-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEssentials.pod
47 lines (34 loc) · 1.83 KB
/
Essentials.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
=begin pod
=head1 NAME
Essentials - The important stuff in Perl 6
=head1 DESCRIPTION
The (arguably) most important things to know about Perl 6 if you're a Perl 5
programmer. For instance, you probably need to know that method calls are now
done with C<.> rather than C<< -> >>. On the other hand, that you need to know
that the left bit shift operator has changed from C<< << >> to C<< +< >> is
less likely. The changes from Perl 5 to Perl 6 are covered much more
exhaustively in the other documents in this set, such as L<Operators.pod> and
C<Functions.pod>.
=head1 SOURCES
I'm taking my information from L<http://doc.perl6.org>, supplemented by the
design documents at L<http://design.perl6.org/> and input from the denizens
of #perl6 on irc.freenode.org
=head2 Sigils
The sigils we know and love are all still there, but they are now
invariant.In other words, while in Perl 5 arrays began with a "@" but
array I<elements> began with a "$", In Perl 6, arrays begin with "@" and
array elements also start with "@". Similarly with hashes and "%". The
first element of C<@a> is C<@a[0]>. The value of a hash element with the
key "foo" is C<%hash{foo}>. Scalars, obviously, retain the "$" sigil.
=head2 Methods and Concatenation
As noted in the L<#DESCRIPTION> section, methods are now called with the dot,
rather than the arrow. So, where in Perl 5 you might have used C<<
$object->method >> in Perl 6 you would use C<$object.method>.
With the dot now being used for method calls, the concatenation operator is
now the tilde. So, C<$thing = "beep" . "boop"> is now C<$thing = "beep" ~
"boop">.
And, further on the subject of methods, many things that were only available
as traditional function calls can now be used as methods. Obvious examples are
functions that operate on arrays. C<pop(@a)> can now be done as C<@a.pop>,
although the former still works.
=end pod