Hi

I am trying to parse a file in perl and decode a HEX code.

Ex:

0x0001

0x0002

0x0003

.

.

.

0xFFFF

I need to convert these hex to binary and make decision based on it.

0x0001 - 0000 0000 0000 0001

0x0003 - 0000 0000 0000 0011

0x0007 - 0000 0000 0000 0111

.

0xFFFF - 1111 1111 1111 1111

Any idea how to code this inteligently without doing 255 if/elsif statements? So like when there are 15 0s and only 1 1 then I do { x }

if 14 0s and 2 1s then { }

if 13 0s and 3 1s then { }

..

if 0 0s and 16 1s then { }

Thanks in advance