3 perldelta - what is new for perl v5.11.0
7 This document describes differences between the 5.10.0 and the 5.11.0
10 =head1 Incompatible Changes
12 =head2 Switch statement changes
14 The handling of complex expressions by the C<given>/C<when> switch
15 statement has been enhanced. There are two new cases where C<when> now
16 inteprets its argument as a boolean, instead of an expression to be used
21 =item flip-flop operators
23 The C<..> and C<...> flip-flop operators are evaluated in boolean context,
24 following their usual semantics; see L<perlop/"Range Operators">.
26 =item defined-or operator
28 A compound expression involving the defined-or operator, as in
29 C<when (expr1 // expr2)>, will be treated as boolean if the first
30 expression is boolean. (This just extends the existing rule that applies
31 to the regular or operator, as in C<when (expr1 || expr2)>.)
35 The next paragraph details more changes brought to the semantics to
36 the smart match operator, that naturally also modify the behaviour
37 of the switch statements where smart matching is implicitly used.
39 =head2 Smart match changes
41 =head3 Changes to type-based dispatch
43 The smart match operator C<~~> is no longer commutative. The behaviour of
44 a smart match now depends primarily on the type of its right hand
45 argument. While the general backwards compatibility is maintained,
46 several changes must be noted:
52 Code references with an empty prototype are no longer treated specially.
53 They are passed an argument like the other code references (even if they
58 C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
59 returns a true value for each key of the hash (resp. element of the
60 array), instead of passing the whole hash or array as a reference to
65 C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
66 hash). No implicit conversion to C<""> is done (as was the case in perl
71 C<$scalar ~~ @array> now always distributes the smart match across the
72 elements of the array. It's true if one element in @array verifies
73 C<$scalar ~~ $element>. This is a generalization of the old behaviour
74 that tested whether the array contained the scalar.
78 The full dispatch table for the smart match operator is given in
79 L<perlsyn/"Smart matching in detail">.
81 =head3 Smart match and overloading
83 According to the rule of dispatch based on the rightmost argument type,
84 when an object overloading C<~~> appears on the right side of the
85 operator, the overload routine will always be called (with a 3rd argument
86 set to a true value, see L<overload>.) However, when the object will
87 appear on the left, the overload routine will be called only when the
88 rightmost argument is a scalar. This way distributivity of smart match
89 across arrays is not broken, as well as the other behaviours with complex
90 types (coderefs, hashes, regexes). Thus, writers of overloading routines
91 for smart match need to worry only with comparing against a scalar, and
92 possibly with stringification overloading; the other cases will be
93 automatically handled consistently.
95 C<~~> will now refuse to work on objects that do not overload it (in order
96 to avoid relying on the object's underlying structure).
98 =head1 Core Enhancements
100 =head1 The C<overloading> pragma
102 This pragma allows you to lexically disable or enable overloading
103 for some or all operations. (Yuval Kogman)
105 =head1 Modules and Pragmata
107 =head2 Pragmata Changes
113 See L</"The C<overloading> pragma"> above.
117 =head1 Utility Changes
121 =head1 Performance Enhancements
123 =head1 Installation and Configuration Improvements
125 =head1 Selected Bug Fixes
129 =item C<-I> on shebang line now adds directories in front of @INC
131 as documented, and as does C<-I> when specified on the command-line.
136 =head1 New or Changed Diagnostics
138 =head1 Changed Internals
140 =head1 Known Problems
142 =head2 Platform Specific Problems
144 =head1 Reporting Bugs
146 If you find what you think is a bug, you might check the articles
147 recently posted to the comp.lang.perl.misc newsgroup and the perl
148 bug database at http://bugs.perl.org/ . There may also be
149 information at http://www.perl.org/ , the Perl Home Page.
151 If you believe you have an unreported bug, please run the B<perlbug>
152 program included with your release. Be sure to trim your bug down
153 to a tiny but sufficient test case. Your bug report, along with the
154 output of C<perl -V>, will be sent off to perlbug@perl.org to be
155 analysed by the Perl porting team.
159 The F<Changes> file for exhaustive details on what changed.
161 The F<INSTALL> file for how to build Perl.
163 The F<README> file for general stuff.
165 The F<Artistic> and F<Copying> files for copyright information.