use Modern::Perl; my $x = 2.3; given($x) { when($_) { say 'match' } # $_ ~~ $x default { say 'no match' } }