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