http://qs321.pair.com?node_id=1069299


in reply to perldelta unclear on 'given's fate

I imagine that given/when will be kept. However, the perception is that their current implementation is highly flawed. A new implementation will probably break some existing uses of given/when, so it makes sense to start warning people about this.

given originally used the lexical $_ rather than the global $_ (but this has changed in 5.18). This was confusing for many people.

when adds a whole extra layer of weird.

Quick quiz! What does this output?

use v5.10; use strict; no warnings; sub two () { 2 } sub three { 3 } sub english_number { my $number = shift; given ($number) { when ( 1 ) { return 'one' } when ( two ) { return 'two' } when ( three ) { return 'three' } when ( 4 ) { return 'four' } default { return 'more' } } } say english_number($_) for 1..5;
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name