in reply to using a hexadecimal mask to create a list of values (that the mask is pointing to)

One way to do it:

#!/usr/bin/perl my @list = ('a', '6', '5', '5', '4', '5', '0', 'e'); my $hex = join '', @list; my $bin = unpack("B*", pack("H*", $hex)); # "101001100101010101000101 +00001110" my $idx = -1; my @tuner_list = map {$idx++; $_ ? $idx : ()} reverse split //, $bin; print "@tuner_list\n"; # 1 2 3 8 10 14 16 18 20 22 25 26 29 31
  • Comment on Re: using a hexadecimal mask to create a list of values (that the mask is pointing to)
  • Download Code