$ perl -Mstrict -Mwarnings -e ' use 5.018; use feature "lexical_subs"; no if $] >= 5.018, warnings => "experimental::smartmatch"; no if $] >= 5.018, warnings => "experimental::lexical_subs"; my ($x, $y) = (1, undef); given ($x) { when (1) { say "\$x == 1" } default { say "\$x != 1" } } given ($y) { when (1) { say "\$y == 1" } default { say "\$y != 1" } } my sub z { say "In z()" } z(); ' $x == 1 $y != 1 In z()