in reply to How to Use a Bitfield to Select Elements of an Array

If the original problem is:

Say I want to select specific items from this list, say, "down", "out" and "left". This might be represented by another array:
@arr = qw ( up down in out left right ); # 6 elements @sel = ( 1, 3, 4 ); @my_items = Magic(@arr, @sel);

Then the following, Perl built-in solution does what you want already:

@my_items = @arr[ @sel ];

I'm not sure if you want to pursue your bit-field path further...

Replies are listed 'Best First'.
Re^2: How to Use a Bitfield to Select Elements of an Array
by ozboomer (Friar) on Feb 15, 2006 at 12:34 UTC
    *Brother*

    I knew I had to be thinking about this too hard...

    Many thanks for reminding me that sometimes you can be too clever for your own good(!)