for (qw(a X b)) { my $id = $1 if /(a)/ or /(b)/; print qq{'$_' -> '$id'\n}; }