use v5.10; use strict; use warnings; my @tests = qw(1 9 17 25 33); my $range_25_32 = [25..32]; # alternatve, maybe(?) faster for my $ref ( @tests ) { given ( $ref ) { when ( [1..8] ) { say "A $ref" } when ( [9..16] ) { say "B $ref" } when ( [17..24] ) { say "C $ref" } when ( $range_25_32 ) { say "D $ref" } default { say "ELSE $ref" } } }