my $highnibble = ((ord $byte[0]) >> 4)); The variable $highnibble prints the right value.