Replace when/default with if/elsif/else

perldelta for 5.18.0 suggests this replacement because the smartmatch family
of features is now "experimental" and produces warnings.