perlquestion
spurperl
Dear monks,
<p>
A few minutes ago I needed to "fold" an array into a hash representing a bag/set. That is, from <code>[a, b, c]</code> I wanted to create <code>{a => 1, b => 1, c => 1}</code>. Without thinking much, I slapped:<p>
<code>
my %bag = map {($_, 1)} @arr;
</code>
<p>
And now I wonder on the merits of this technique. I recall seeing it discussed in the monastery before, I can't don't know what to look for in the Supersearch. Any fellow monks with memory better than mine ?<p>
What I want to know, basically, is whether it's a Good Way (TM), what are the alternatives, etc.