in reply to Re^2: Simple regex to remove all but a list of words
in thread Simple regex to remove all but a list of words

So we can start the battle of style: would you rather have a clumsy, useless loop (or map), or rather two clumsy, lines, one with declaration, one with initialization?

Perl 6 to the help, if you don't mind wrapping your head around function style a bit, you can use the zip operator Z:

pugs> my @good = <a b c> ("a", "b", "c") pugs> @good Z 1 xx @good (("a", 1), ("b", 1), ("c", 1))

Pugs doesn't flatten the list correctly, so you can't assign it to a hash in pugs, but a correct implementation will allow that. (Notice also the beauty of not needing any grouping parenthesis, because the precedence levels are just right(tm)).

# Perl 6: my %hash = @good Z 1 xx @good