Update Archive::Extract to 0.34
[p5sagit/p5-mst-13.2.git] / pod / perl5110delta.pod
CommitLineData
7120b314 1=head1 NAME
2
3perldelta - what is new for perl v5.11.0
4
5=head1 DESCRIPTION
6
7This document describes differences between the 5.10.0 and the 5.11.0
9948897e 8development releases.
7120b314 9
10=head1 Incompatible Changes
11
8b8da387 12=head2 Switch statement changes
13
14The handling of complex expressions by the C<given>/C<when> switch
1710b4c0 15statement has been enhanced. There are two new cases where C<when> now
412304fb 16interprets its argument as a boolean, instead of an expression to be used
8b8da387 17in a smart match:
18
19=over 4
20
8b8da387 21=item flip-flop operators
22
98814a2b 23The C<..> and C<...> flip-flop operators are now evaluated in boolean
24context, following their usual semantics; see L<perlop/"Range Operators">.
25
26Note that, as in perl 5.10.0, C<when (1..10)> will not work to test
27whether a given value is an integer between 1 and 10; you should use
28C<when ([1..10])> instead (note the array reference).
29
30However, contrary to 5.10.0, evaluating the flip-flop operators in boolean
31context ensures it can now be useful in a C<when()>, notably for
32implementing bistable conditions, like in:
33
34 when (/^=begin/ .. /^=end/) { ... }
8b8da387 35
36=item defined-or operator
37
38A compound expression involving the defined-or operator, as in
39C<when (expr1 // expr2)>, will be treated as boolean if the first
40expression is boolean. (This just extends the existing rule that applies
41to the regular or operator, as in C<when (expr1 || expr2)>.)
42
43=back
44
98814a2b 45The next section details more changes brought to the semantics to
8b8da387 46the smart match operator, that naturally also modify the behaviour
47of the switch statements where smart matching is implicitly used.
48
49=head2 Smart match changes
50
51=head3 Changes to type-based dispatch
52
53The smart match operator C<~~> is no longer commutative. The behaviour of
54a smart match now depends primarily on the type of its right hand
ee18cc6c 55argument. Moreover, its semantics has been adjusted for greater
56consistency or usefulness in several cases. While the general backwards
57compatibility is maintained, several changes must be noted:
8b8da387 58
59=over 4
60
61=item *
62
63Code references with an empty prototype are no longer treated specially.
64They are passed an argument like the other code references (even if they
65choose to ignore it).
66
67=item *
68
69C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
9091a618 70returns a true value for each key of the hash (or element of the
8b8da387 71array), instead of passing the whole hash or array as a reference to
72the subroutine.
73
74=item *
75
ee18cc6c 76Due to the commutativity breakage, code references are no longer
77treated specially when appearing on the left of the C<~~> operator,
78but like any vulgar scalar.
79
80=item *
81
8b8da387 82C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
83hash). No implicit conversion to C<""> is done (as was the case in perl
845.10.0).
85
86=item *
87
88C<$scalar ~~ @array> now always distributes the smart match across the
89elements of the array. It's true if one element in @array verifies
90C<$scalar ~~ $element>. This is a generalization of the old behaviour
91that tested whether the array contained the scalar.
92
93=back
94
95The full dispatch table for the smart match operator is given in
96L<perlsyn/"Smart matching in detail">.
97
98=head3 Smart match and overloading
99
100According to the rule of dispatch based on the rightmost argument type,
101when an object overloading C<~~> appears on the right side of the
102operator, the overload routine will always be called (with a 3rd argument
103set to a true value, see L<overload>.) However, when the object will
104appear on the left, the overload routine will be called only when the
9091a618 105rightmost argument is a simple scalar. This way distributivity of smart match
8b8da387 106across arrays is not broken, as well as the other behaviours with complex
107types (coderefs, hashes, regexes). Thus, writers of overloading routines
ee18cc6c 108for smart match mostly need to worry only with comparing against a scalar,
109and possibly with stringification overloading; the other common cases
110will be automatically handled consistently.
8b8da387 111
112C<~~> will now refuse to work on objects that do not overload it (in order
665f5e98 113to avoid relying on the object's underlying structure). (However, if the
114object overloads the stringification or the numification operators, and
115if overload fallback is active, it will be used instead, as usual.)
8b8da387 116
7120b314 117=head1 Core Enhancements
118
ef55af2a 119=head2 The C<overloading> pragma
1839a850 120
121This pragma allows you to lexically disable or enable overloading
122for some or all operations. (Yuval Kogman)
123
71e9c532 124=head2 C<\N> regex escape
125
126A new regex escape has been added, C<\N>. It will match any character that
127is not a newline, independently from the presence or absence of the single
128line match modifier C</s>. (If C<\N> is followed by an opening brace and
129by a letter, perl will still assume that a Unicode character name is
130coming, so compatibility is preserved.) (Rafael Garcia-Suarez)
131
5ee651a9 132=head2 Parallel tests
133
134The core distribution can now run its regression tests in parallel on
135Unix-like platforms. Instead of running C<make test>, set C<TEST_JOBS> in
136your environment to the number of tests to run in parallel, and run
137C<make test_harness>. On a Bourne-like shell, this can be done as
138
139 TEST_JOBS=3 make test_harness # Run 3 tests in parallel
140
141An environment variable is used, rather than parallel make itself, because
142L<TAP::Harness> needs to be able to schedule individual non-conflicting test
143scripts itself, and there is no standard interface to C<make> utilities to
144interact with their job schedulers.
145
7120b314 146=head1 Modules and Pragmata
147
1839a850 148=head2 Pragmata Changes
149
150=over 4
151
152=item C<overloading>
153
154See L</"The C<overloading> pragma"> above.
155
156=back
157
7120b314 158=head1 Utility Changes
159
160=head1 Documentation
161
162=head1 Performance Enhancements
163
164=head1 Installation and Configuration Improvements
165
166=head1 Selected Bug Fixes
167
54ad55c5 168=over 4
169
170=item C<-I> on shebang line now adds directories in front of @INC
171
172as documented, and as does C<-I> when specified on the command-line.
173(Renée Bäcker)
174
175=back
176
7120b314 177=head1 New or Changed Diagnostics
178
179=head1 Changed Internals
180
181=head1 Known Problems
182
183=head2 Platform Specific Problems
184
185=head1 Reporting Bugs
186
187If you find what you think is a bug, you might check the articles
188recently posted to the comp.lang.perl.misc newsgroup and the perl
189bug database at http://bugs.perl.org/ . There may also be
190information at http://www.perl.org/ , the Perl Home Page.
191
192If you believe you have an unreported bug, please run the B<perlbug>
193program included with your release. Be sure to trim your bug down
194to a tiny but sufficient test case. Your bug report, along with the
195output of C<perl -V>, will be sent off to perlbug@perl.org to be
196analysed by the Perl porting team.
197
49f8307e 198If the bug you are reporting has security implications, which make it
199inappropriate to send to a publicly archived mailing list, then please send
200it to perl5-security-report@perl.org. This points to a closed subscription
201unarchived mailing list, which includes all the core committers, who be able
202to help assess the impact of issues, figure out a resolution, and help
203co-ordinate the release of patches to mitigate or fix the problem across all
204platforms on which Perl is supported. Please only use this address for security
205issues in the Perl core, not for modules independently distributed on CPAN.
206
7120b314 207=head1 SEE ALSO
208
209The F<Changes> file for exhaustive details on what changed.
210
211The F<INSTALL> file for how to build Perl.
212
213The F<README> file for general stuff.
214
215The F<Artistic> and F<Copying> files for copyright information.
216
217=cut