This is how I would do it, but I generally use a non-capturing group whenever possible for clarity:
if ( $a =~ /^ (?: ABA | SCO | ACC | PHC | GHF ) $/x ) { ... }
Note that this is more for capturing intent than performance. When I see a capture group (...), I assume we will be using whatever was captured. In this case, since we are capturing the entire string, $a == $1.
Probably not worth the nitpick :)
Best,
Jim
πάντων χρημάτων μέτρον έστιν άνθρωπος.
|