my %keywords = map { $_ => 1 } qw/L CLI BNE LTR .../; ... #later in the code if (exists $keywords{$whatever_is_suspected_to_be_a_keyword}) { # it is a keyword ... } ...