[Melbourne-pm] given/when and smartmatch

Toby Corkindale toby.corkindale at strategicdata.com.au
Wed May 29 19:18:48 PDT 2013


As I'm sure you all noticed, Perl 5.18 is deprecating smartmatch, and 
the associated given/when syntax.
(You can still have it, but you have to enable it as an experimental 
feature, and it may go away or change drastically in future perl versions)

I wondered how you feel about this?

I'm sad, because I rather like using the switch stuff - ie. given/when



Footnote:
Although I was perpetually irritated that you couldn't use given() as an 
rval, so I would always end up with patterns like this:

sub foo {
   given (shift) {
     when (/yadda/) { return a }
     when (@stuff) { return b }
     default { return c }
   }
}

my $result = foo($thing)




More information about the Melbourne-pm mailing list