in reply to Interesting Use of Grep

Note that the nested hash lookups are done for each iteration. It would be fastest to factor that out of the loop. If you can arrange it, turning the actual grep into a hash lookup is even faster, and I personally like the idiom:
if ($is_wanted{$my_variable_here}) { # Do something }
because I can turn the name of the hash into what is in effect an inline comment about how I am thinking. (Note that comments embedded within your code like this are more likely to be maintained than comments insert into code.)

In fact I like it enough to sometimes do that even when I know that building the hash is going to be slower.