my @arr = qw (and you will be pleased with the results); my $mask = 0x2b; # 0 0 1 0 1 0 1 1 my @result = wave_hands( $mask, @arr ) # returns qw(will pleased the results)