Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Individually testing for single character alternatives:
if ($cmd !~ m{\A (?: a | d | i | q | r | w | x ) \z}xms) {
carp "Unknown command: $cmd";
next COMMAND;
}
may make your regex slightly more readable. But that gain isn't sufficient to compensate for the heavy performance penalty this approach imposes. Furthermore, the cost of testing separate alternatives this way increases linearly with the number of alternatives to be tested.
The equivalent character class:
if ($cmd !~ m{\A [adiqrwx] \z}xms) {carp "Unknown command: $cmd";next COMMAND;}
does exactly the same job, but 10 times faster. And it costs the same no matter how many characters are later added to the set.