use Parse::RecDescent; my @colors = ('periwinkle','indigo'); my $grammar = q[ order: quantity color item quantity: /\d+/ color: item: 'pen' | 'pencil' ]; my $parser = new Parse::RecDescent ($grammar); $parser->Extend("color: '" . join(q['|'],@colors) . "'" ); #### my $grammar = q[ order: quantity color item quantity: /\d+/ color: '] . join(q['|'],@colors) . q[' item: 'pen' | 'pencil' ];