for my $x ( 1,2,3,4,6,8,12,13,14,42,43,134,143 ) { if ( $x =~ m{\A (?: 4?3 | 1?4 ) \z}x ) { print "$x: Plan A"; } else { print "$x: Plan B"; } }