my $bitstring = unpack('B*', pack('H*', '40000000000000000000000000000000')); my $result = substr($bitstring, $switchPortNumber, 1) eq '1';