http://qs1969.pair.com?node_id=1069420


in reply to Re^5: perldelta unclear on 'given's fate
in thread perldelta unclear on 'given's fate

I actually think that's pretty cool, despite my desire to see a native switch. I have often use hash constructs to accomplish switch-like behavior, and I think that the for ( $var ) ... approach is much nicer...

# Example of the hash-construct "switch", which is limited and has no +"default". # The output of this code is "abc" use Moo; my $val = 'c'; my @args = qw( abc ); my $obj = __PACKAGE__->new(); { a => sub { say 'a' }, b => \&b, c => sub { $obj->c( @_ ) }, }->{ $val }->( @args ); sub b { say 'b' }; sub c { shift; say for @_ };

Tommy
A mistake can be valuable or costly, depending on how faithfully you pursue correction