and has now been fixed. This fix could however potentially cause a change
in behaviour of some code.
+=head2 C<given> return values
+
+Starting from this release, C<given> blocks returns the last evaluated
+expression, or an empty list if the block was exited by C<break>. Thus you
+can now write:
+
+ my $type = do {
+ given ($num) {
+ break when undef;
+ 'integer' when /^[+-]?[0-9]+$/;
+ 'float' when /^[+-]?[0-9]+(?:\.[0-9]+)?$/;
+ 'unknown';
+ }
+ };
+
+See L<perlsyn/Return value> for details.
+
=head1 Core Enhancements
XXX New core language features go here. Summarise user-visible core language
=head3 Return value
When a C<given> statement is also a valid expression (e.g.
-when it's the last statement of a block), it returns :
+when it's the last statement of a block), it evaluates to :
=over 4
=item *
-An empty list as soon as an explicit C<break> is encountered.
+an empty list as soon as an explicit C<break> is encountered.
=item *
-The value of the last evaluated expression of the successful
+the value of the last evaluated expression of the successful
C<when>/C<default> clause, if there's one.
=item *
-The value of the last evaluated expression of the C<given> block if no
-condition was true.
+the value of the last evaluated expression of the C<given> block if no
+condition is true.
=back
-Note that, unlike C<if> and C<unless>, both C<when> and C<default> always
-themselves return an empty list.
+In both last cases, the last expression is evaluated in the context that
+was applied to the C<given> block.
+
+Note that, unlike C<if> and C<unless>, failed C<when> statements always
+evaluate to an empty list.
my $price = do { given ($item) {
when ([ 'pear', 'apple' ]) { 1 }
'unknown';
} };
-C<given> blocks can't currently be used as proper expressions. This
+Currently, C<given> blocks can't always be used as proper expressions. This
may be addressed in a future version of perl.
=head3 Switching in a loop